tobler.dasymetric.extract_raster_features¶
-
tobler.dasymetric.extract_raster_features(gdf, raster_path, pixel_values=
None, nodata=255, n_jobs=-1, collapse_values=False)[source]¶ Generate a geodataframe from raster data by polygonizing contiguous pixels with the same value using rasterio’s features module.
- Parameters:¶
- gdf : geopandas.GeoDataFrame¶
geodataframe defining the area of interest. The input raster will be clipped to the extent of the geodataframe
- raster_path : str¶
path to raster file, such as downloaded from <https://lcviewer.vito.be/download>
- pixel_values : list-like, optional¶
subset of pixel values to extract, by default None. If None, this function may generate a very large geodataframe
- nodata : int, optional¶
pixel value denoting “no data” in input raster
- n_jobs : int¶
[Optional. Default=-1] Number of processes to run in parallel. If -1, this is set to the number of CPUs available
- collapse_values : bool, optional¶
If True, multiple values passed to the pixel_values argument are treated as a single type. I.e. polygons will be generated from any contiguous collection of values from pixel_types, instead of unique polygons generated for each value This can dramatically reduce the complexity of the resulting geodataframe a fewer polygons are required to represent the study area.
- Returns:¶
geodataframe whose rows are the zones extracted by the rasterio.features module. The geometry of each zone is the boundary of a contiguous group of pixels with the same value; the value column contains the pixel value of each zone.
- Return type:¶