Example - Use a rasterize function when creating a raster
[18]:
import geopandas
from functools import partial
from geocube.rasterize import rasterize_image
from geocube.api.core import make_geocube
%matplotlib inline
[19]:
gdf = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
[22]:
geo_grid = make_geocube(
vector_data=gdf,
measurements=['pop_est'],
resolution=(-3.0, 3.0),
)
geo_grid["pop_est"].plot()
[22]:
<matplotlib.collections.QuadMesh at 0x190f9eeb0>
[23]:
geo_grid = make_geocube(
vector_data=gdf,
measurements=['pop_est'],
resolution=(-3.0, 3.0),
rasterize_function=partial(rasterize_image, all_touched=True),
)
geo_grid["pop_est"].plot()
[23]:
<matplotlib.collections.QuadMesh at 0x1910469d0>
[ ]: