Raster Preprocessing
Overview
This merge request adds a number of features useful for preprocessing rasters. Broadly, these include (1) a variety of preprocessing commands, (2) Factory functions that build Raster objects from various sources, and (3) A few properties related to raster transforms/bounds.
Closes #72 (closed), #70 (closed), #69 (closed), #67 (closed), #61 (closed), #36 (closed)
Preprocessing
This is the bulk of the merge request. New commands include:
- Raster.from_polygons -- Useful for converting a fire perimeter to a raster mask
- Raster.buffer -- Applied to a perimeter mask to determine the domain of an assessment
- Raster.reproject -- Matches a raster's CRS, resolution, and grid alignment to another raster
- Raster.clip -- Matches a raster's bounds to the same bounds as another raster
- Raster.find -- Locates raster pixels that match the specified values (output is a raster mask -- useful for EVT data)
- Raster.set_range -- Constrains a raster's data values to a valid range (useful for dNBR and kf-factors)
- Raster.fill -- Replaces NoData pixels with the indicated data value
Factory functions
These allow a user to create a raster object from a specific type of input with additional options. The factories include: from_array (already existed), from_file, from_rasterio, from_pysheds, and from_polygons
The key new options are in Raster.from_file. This adds "driver" and "band" options to specify how data should be read in from file. Also adds the "isbool" option, which converts a loaded raster's values to a boolean array. The idea being to replace things like:
>>> iswater = Raster(path).values.copy().astype(bool)
with something like
>>> iswater = Raster.from_file(path, isbool=True)
Transform properties
Added a few new transform-related properties. Nothing big here, but possibly useful when reprojecting/clipping rasters:
left/right/top/bottom -- The spatial coordinate of one of the raster's edges
dx, dy -- The change in spatial coordinate when incrementing one row/column