rasterize_categorical#
- geobricks.rasterize_categorical(data_gdf, grid_gdf, *, is_polygon=False, is_point=False)[source]#
Rasterize a categorical column of a geopandas.GeoDataFrame, according to a vector grid. For consistency, the geopandas.GeoDataFrame should contain only one level of the categorical variable. This function returns the count of points in each raster cell (if
is_point = True) or the area covered by polygons in each raster cell (ifis_polygon = True).Parameters#
- data_gdfgeopandas.GeoDataFrame
Input frame containing the column to rasterize. This function will not differentiate the different levels of the categorical variable. It is expected that
data_gdfcontains only one signle level.- grid_gdfgeopandas.GeoDataFrame
Vector grid composed: one rectangle will correspond to one raster cell.
- is_polygonbool
Whether the input frame is a polygon vector dataset or not.
- is_pointbool
Whether the input frame is a point vector dataset or not.
Returns#
- coverxarray.DataArray
DataArray containing the results.
if
is_polygon = True: the sum of area intersecting each cell will be returnedif
is_point = True: the count of points in each cell will returned