sample_raster#

module wntr.gis.geospatial

sample_raster(A, filepath, bands=1)[source]#

Sample a raster (e.g., GeoTIFF file) using Points in GeoDataFrame A.

This function can take either a filepath to a raster or a virtual raster (VRT), which combines multiple raster tiles into a single object. The function opens the raster(s) and samples it at the coordinates of the point geometries in A. This function assigns nan to values that match the raster’s nodata attribute. These sampled values are returned as a Series which has an index matching A.

Parameters:
  • A (GeoDataFrame) – GeoDataFrame containing Point geometries

  • filepath (str) – Path to raster or alternatively a virtual raster (VRT)

  • bands (int or list[int] (optional, default = 1)) – Index or indices of the bands to sample (using 1-based indexing)

Returns:

Pandas Series containing the sampled values for each geometry in gdf

Return type:

Series