imod.prepare.gdal_rasterize#

imod.prepare.gdal_rasterize(path, column, like=None, nodata=None, dtype=None, spatial_reference=None, all_touched=False)[source]#

Use GDAL to rasterize a vector file into an xarray.DataArray.

Can be significantly more efficient than rasterize. This doesn’t load the vector data into a GeoDataFrame and loops over the individual shapely geometries like rasterio.rasterize does, but loops over the features within GDAL instead.

Parameters
  • path (str or pathlib.Path) – path to OGR supported vector file (e.g. a shapefile)

  • column (str) – column name of column to burn into raster

  • like (xr.DataArray, optional) – example of raster

  • nodata (int, float; optional) –

  • dtype (numpy.dtype, optional) –

  • spatial_reference (dict, optional) –

    Optional dict to avoid allocating the like DataArray. Used if template is None. Dict has keys “bounds” and “cellsizes”, with:

    • bounds = (xmin, xmax, ymin, ymax)

    • cellsizes = (dx, dy)

  • all_touched (bool) – If True: all pixels touched by lines or polygons will be updated, not just those on the line render path, or whose center point is within the polygon. Default value is False.

Returns

rasterized

Return type

xr.DataArray