isce3 icon indicating copy to clipboard operation
isce3 copied to clipboard

Potential issues with resampling the water mask raster

Open gmgunter opened this issue 4 months ago • 1 comments

The function _project_water_to_geogrid() in nisar/workflows/geocode_insar.py is used to re-project the input water distance map raster onto the output geo grid and convert it into a binary water mask.

https://github.com/isce-framework/isce3/blob/8cc6581525e608cc95fdcd883dac87e08f83e7d0/python/packages/nisar/workflows/geocode_insar.py#L180-L213

There are couple of potential issues with the implementation that @gshiroma, @nemo794, and I noticed while reviewing a similar implementation in the Static Layers PR:

  1. The water distance map is resampled onto the output grid using the "mode" resampling method before converting the distance map to a binary mask. This might be an issue because "mode" resampling is not really appropriate for non-categorical data.

    Imagine the case where a small region of the water distance map is 25% water pixels and 75% non-water pixels, but the non-water pixels all have different values. In this case, the "mode" method would consider this region to be water, even though it is actually predominantly non-water.

    In order to address this, we should either change the resampling method (e.g. to "near" for nearest-neighbor resampling) or else convert the water distance to a binary mask before re-projected it onto the output grid. The latter option may be undesirable in the case where the input water distance map covers a much larger area than the output geo grid -- in that case, we are doing a lot of unnecessary processing on parts of the water distance map that don't overlap the region of interest.

  2. When converting the water distance map to a binary mask, the code doesn't respect the fill value of 255. Invalid pixels (with a value of 255) in the input raster will be treated the same as non-water pixels in the output binary mask.

gmgunter avatar Oct 01 '25 00:10 gmgunter