exactextract.raster

Classes

RasterSource

Source from which raster data can be read.

GDALRasterSource

RasterSource backed by GDAL

NumPyRasterSource

RasterSource backed by a NumPy array

RasterioRasterSource

RasterSource backed by rasterio

XArrayRasterSource

RasterSource backed by xarray

Module Contents

class exactextract.raster.RasterSource[source]

Source from which raster data can be read.

A RasterSource provides the ability to read subsets of a single band of raster data. Several implementations are included in exactextract:

class exactextract.raster.GDALRasterSource(ds, band_idx: int = 1, *, name=None)[source]

RasterSource backed by GDAL

Parameters:
  • ds – A gdal.Dataset or path from which one can be opened

  • band_idx – 1-based numerical index of band to read

  • name – source name, to be used in generating field names for results

res()[source]
extent()[source]
nodata_value()[source]
read_window(x0, y0, nx, ny)[source]
srs_wkt()[source]
class exactextract.raster.NumPyRasterSource(mat, xmin=None, ymin=None, xmax=None, ymax=None, *, nodata=None, name=None, srs_wkt=None)[source]

RasterSource backed by a NumPy array

Create a RasterSource that references a NumPy array.

If spatial extent arguments are not provided, the extent will be assumed to be from (0,0) to (nx,ny).

Parameters:
  • mat – a two-dimensional NumPy array. Masked arrays are supported.

  • xmin – x coordinate of left edge

  • ymin – y coordinate of bottom edge

  • xmax – x coordinate of right edge

  • ymax – y coordinate of top edge

  • nodata – Optional value used to indicate missing data.

  • name – source name, to be used in generating field names for results

  • srs_wkt – WKT string indicating the spatial reference system.

res()[source]
srs_wkt()[source]
extent()[source]
nodata_value()[source]
read_window(x0, y0, nx, ny)[source]
class exactextract.raster.RasterioRasterSource(ds, band_idx=1, *, name=None)[source]

RasterSource backed by rasterio

Parameters:
  • ds – A rasterio.DatasetReader or path from which one can be opened

  • band_idx – 1-based numerical index of band to read

  • name – source name, to be used in generating field names for results

res()[source]
srs_wkt()[source]
extent()[source]
nodata_value()[source]
read_window(x0, y0, nx, ny)[source]
class exactextract.raster.XArrayRasterSource(ds, band_idx=1, *, name=None)[source]

RasterSource backed by xarray

The rio-xarray extension is used to retrieve metadata such as the array extent, resolution, and spatial reference system.

Parameters:
  • ds – An xarray DataArray or a path from which one can be read.

  • band_idx – 1-based numerical index of band to read

  • name – source name, to be used in generating field names for results

srs_wkt()[source]
res()[source]
extent()[source]
nodata_value()[source]
read_window(x0, y0, nx, ny)[source]