natcap / pygeoprocessing

Geoprocessing operations for Python
https://pygeoprocessing.readthedocs.io/en/latest/
Other
80 stars 9 forks source link

Support notation for warping population rasters #263

Open phargogh opened 2 years ago

phargogh commented 2 years ago

Use case 1: NCI Water Quality

In the NCI water quality work, some of the rasters being aligned as a part of the geoprocessing pipeline represent populations with counts per pixel. So then a population raster cattle.tif has to go through this workflow:

  1. cattle.tif must be converted to density of cattle per unit area (square meters in this case)
  2. We call align_and_resize_raster_stack
  3. Convert the aligned cattle.tif back to population counts per pixel.

In the NCI context, we're working within the wgs84 coordinate system, so all of these rasters have pixel areas that vary by latitude. Note that pygeoprocessing._create_latitude_m2_area_column() is helpful for this unit conversion, so part of the work is already done.

Use Case 2: InVEST Urban Nature Access

In the Urban Nature Access model, we also do the unit conversion step outlined above, but because the dataset is in assumed to be in a projected coordinate system, we just do the same scalar unit conversion across the whole raster.

Design Objective

I would like for pygeoprocessing.align_and_resize_raster_stack (and pygeoprocessing.warp_raster by extension) to offer some kind of notation or option to handle the unit conversion before and after the warping itself so we don't have to keep rewriting the same raster_calculator operations.

In an ideal world, I would hope that this function would work for both use cases above, where the pixel size can be inferred from the spatial reference, including if the pixel size varies spatially. Even if we don't initially have a general-case solution, handling the 2 use cases above would be a very good start.

davemfish commented 2 years ago

Great idea! This is the sort of feature that sets pygeoprocessing apart from other GIS libraries that are much less aware of the scientific domains where they are applied.