rasterstats.io module¶
-
class
rasterstats.io.
Raster
(raster, affine=None, nodata=None, band=1)[source]¶ Bases:
object
Raster abstraction for data access to 2/3D array-like things
Use as a context manager to ensure dataset gets closed properly:
>>> with Raster(path) as rast: ...
Parameters: raster: 2/3D array-like data source, required
Currently supports paths to rasterio-supported rasters and numpy arrays with Affine transforms.
affine: Affine object
Maps row/col to coordinate reference system required if raster is ndarray
nodata: nodata value, optional
Overrides the datasource’s internal nodata if specified
band: integer
raster band number, optional (default: 1)
Methods
index
(x, y)Given x,y in crs, return the (column, row) on the raster read
([bounds, window, masked, nan_as_nodata])Performs a boundless read against the underlying array source -
read
(bounds=None, window=None, masked=False, nan_as_nodata=False)[source]¶ Performs a boundless read against the underlying array source
Parameters: bounds: bounding box
in w, s, e, n order, iterable, optional
window: rasterio-style window, optional
bounds OR window are required, specifying both or neither will raise exception
masked: boolean
return a masked numpy array, default: False bounds OR window are required, specifying both or neither will raise exception
nan_as_nodata: boolean
Treat NaN values as nodata, default: False
Returns: Raster object with update affine and array info
-