API reference
rusterize.rusterize(data, like=None, res=None, out_shape=None, extent=None, field=None, by=None, burn=None, fun='last', background=np.nan, encoding='xarray', all_touched=False, tap=False, dtype='float64')
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
(GeoDataFrame, GeoSeries, DataFrame, list, ndarray)
|
Input data to rasterize.
|
required |
|
xarray.DataArray or xarray.Dataset (default: None)
|
Template array used as a spatial blueprint (resolution, shape, extent). Mutually exclusive with |
None
|
|
tuple or list (default: None)
|
Pixel resolution defined as (xres, yres). |
None
|
|
tuple or list (default: None)
|
Output raster dimensions defined as (nrows, ncols). |
None
|
|
`tuple` or `list` (default: None)
|
Spatial bounding box defined as |
None
|
|
`str` (default: None)
|
Column name to use for pixel values. Mutually exclusive with |
None
|
|
`str` (default: None)
|
Column used for grouping. Each group is rasterized into a distinct band in the output. Not considered when input is list or numpy.ndarray. |
None
|
|
`int`, `float`, or `numpy.ndarray` (default: None)
|
A static value or a list of values to apply to each geometries. If a |
None
|
|
`str` (default: "last")
|
Pixel function to use when burning geometries. Available options: |
'last'
|
|
`int` or `float` (default: numpy.nan)
|
Value assigned to pixels not covered by any geometry. |
nan
|
|
`str` (default: "xarray")
|
The format of the returned object: |
'xarray'
|
|
`bool` (default: False)
|
If True, every pixel touched by a geometry is burned. |
False
|
|
`bool` (default: False)
|
Target Aligned Pixels: aligns the extent to the pixel resolution. |
False
|
|
`str` (default: "float64")
|
Output data type (e.g., |
'float64'
|
Returns:
| Type | Description |
|---|---|
xarray.DataArray, numpy.ndarray, or a sparse array in COO format.
|
|
Notes
If encoding is "numpy" or input is list or numpy.ndarray, the return array is without any spatial reference.
When any of res, out_shape, or extent is not provided, it is inferred from the other arguments when applicable.
If like is specified, res, out_shape, and extent are inferred from the like DataArray or Dataset.
Unless extent is specified, a half-pixel buffer is applied to avoid missing points on the border.
The logics dictating the final spatial properties of the rasterized geometries follow those of GDAL.
If field is not in data, then a default burn value of 1 is rasterized.
A None value for dtype corresponds to the default of that dtype. An illegal value for a dtype will be replaced with the default of that dtype.
For example, a background=np.nan for dtype="uint8" will become background=0, where 0 is the default for uint8.
SparseArray
Returned when encoding="sparse". A COO-format sparse array with three converters:
to_xarray()→xarray.DataArrayto_numpy()→numpy.ndarrayto_frame()→polars.DataFrame