onstove.OnStove.raster_to_dataframe#
- OnStove.raster_to_dataframe(layer: RasterLayer | str, name: str | None = None, method: str = 'sample', fill_nodata_method: str | None = None, fill_default_value: float | int = 0)#
Takes a
RasterLayerand a method (sampleorread) and extracts the values from the raster layer to the main GeoDataFrame (gdf).It uses the coordinates of the population points (previously extracted with the
population_to_dataframe()method) to either sample the values from the dataset (ifsampleis used) or read therowsandcolsfrom the array (ifreadis used). The further requires that the raster dataset is aligned with the used population layer.- Parameters:
- layer: RasterLayer or path to the raster
Raster layer to extract values from. If the method
sampleis used, the layer must be provided as the path to the raster file.- name: str, optional
Name to use for the column of the extracted data in the
gdf.- method: str, default ‘sample’
Method to use when extracting the data. If
sample, the values will be sampled using the coordinates of the point of the GeoDataFrame (gdf), which have been previously defined by the population layer. ifread, the values are extracted using the therowsandcolsattributes, which have been previously extracted using the population layer.- fill_nodata_method: str, optional
Method to use to fill the no data. Currently only
interpolateis available.- fill_default_value: float or int, default 0
Default value to use to fill in the no data. This will be used for cells that fall outside the search radius (currently of 100) if the
interpolatemethod is selected, and for all the nodata values ifNoneis used as method.