natcap / invest

InVEST®: models that map and value the goods and services from nature that sustain and fulfill human life.
Apache License 2.0
168 stars 68 forks source link

Urban Nature Access: some outputs should reflect nodata pixels in population raster #1326

Closed phargogh closed 1 month ago

phargogh commented 1 year ago

@Yingjie4Science mentioned in a slack message that while some raster outputs of the Urban Nature Access model have nodata holes where the population raster is nodata, there are other rasters (urban_nature_supply.tif and urban_nature_balance_totalpop.tif were specifically called out) that seem like they should also have nodata where the population raster is nodata.

This is specifically using the greenspace execution mode with dichotomy kernel.

I think this is a bug in the model, but I'm looking into it a bit more to figure out why.

phargogh commented 1 year ago

Here's a summary of what I've found so far, summarized as 4 representative files:

Screenshot 2023-06-14 at 10 14 50 AM
  1. The LULC has no nodata holes.
  2. The population raster has some nodata holes in places where there are no residents, like in Golden Gate Park.
  3. The output file output/urban_nature_balance_percapita_demand100.tif ("demand per capita") has valid pixel values for the entire raster.
  4. The output file output/urban_nature_balance_totalpop.tif ("balance") has valid pixel values only where both the LULC and the population rasters have valid pixel values.

The question here is: should the demand per capita raster have valid pixel values where the LULC or population rasters do not?

Functionally, the model isn't doing anything wrong here. The way that we are using a non-normalized convolution is to add up (and potentially weight) all of the people within a certain radius of some urban nature. Thus, a pixel that is nodata in the LULC could, in fact, have nonzero people within the search radius and therefore have a computed value, as we see in the demand per capita raster. The balance raster, on the other hand, is directly computed as the product of another output with the population raster, so if the population raster is nodata, balance cannot be calculated.

But, I agree with the notion that we might want to be more consistent with which pixels we want to have as outputs and mask accordingly.

Yingjie4Science commented 1 year ago

@phargogh To your question "should the demand per capita raster have valid pixel values where the LULC or population rasters do not?"

For the outputs -- supply raster and balance_percap, would it be a good idea that the model can mask the pixels outside of the boundary?

Yingjie4Science commented 1 year ago

After filling the NA in Pop image

phargogh commented 1 month ago

I think we resolved this by deciding that the population raster really needed to have its nodata values filled. Closing this issue, but feel free to reopen if needed!