model icon indicating copy to clipboard operation
model copied to clipboard

Re-sampling strategy

Open lillythomas opened this issue 2 years ago • 3 comments

Our 3 data products scoped for v0 training (https://github.com/Clay-foundation/model/issues/19, https://github.com/Clay-foundation/model/issues/18, https://github.com/Clay-foundation/model/issues/20) have a median spatial resolution of 20 meters. We'll assume a single resolution model for v0, using 20m resolution to standardize inputs. We'll need to select an appropriate interpolation method for specifically the DEM and S1 inputs.

lillythomas avatar Nov 03 '23 12:11 lillythomas

Just a note that in #27, we've went with resampling to a pixel resolution of 10m for Sentinel-2 and the DEM (Sentinel-1 RTC already has a pixel resolution of 10m, though see https://github.com/Clay-foundation/model/issues/19#issuecomment-1797316063). The resampling is using stackstac.stack's default resampling which is Nearest Neighbour (rasterio.enums.Resampling.nearest).

For Sentinel-2 optical imagery, nearest neighbor resampling is fine, but for the Copernicus DEM, we might want to consider bilinear resampling which compromises between pixel value preservation (nearest neighbor) and smoothing (cubic resampling), see e.g. answers like https://gis.stackexchange.com/questions/102868/best-resampling-method-for-dem-reprojection-in-qgis.

weiji14 avatar Nov 16 '23 20:11 weiji14

Originally posted by @MaxLenormand in https://github.com/Clay-foundation/model/issues/200

2. Copernicus DEM nearest neighbour resampling (?)

I followed the basic tutorial to get MGRS tiles over Puri India and checked the tiles in QGIS, and noticed the Copernicus DEM, band 13, seems to be interpolated to nearest neighbour, i.e. that pixels are resampled from 30m to identical values of 3x3 pixels of 10x10 meters, with all the same value. Here using QGIS's Value Tool plugin I can see there are 3 pixels, with the DEM raster not changing value on a 3x3 grid

CleanShot 2024-03-27 at 20 19 54

I was wondering if there was a reason for not interpolating using something like a bilinear that might smooth the DEM more? I feel like this might weight the edges of these 3x3 grids more heavily in changes compared to the central pixel, when that's not really how the terrain is? I didn't find the code that resamples all datasets to the 10m, so may have gotten that wrong, this is only based on my visual interpretation in QGIS.

@yellowcap, can you make sure for the v1 data pipeline (https://github.com/Clay-foundation/model/issues/178) that we use bilinear interpolation for Copernicus DEM? We'll need to override stackstac's default Nearest Neighbour interpolation. Thanks!

weiji14 avatar Mar 27 '24 23:03 weiji14

Thanks for the hint! Definitively something to integrate - and wish we had caught that for v0.2 😄 V1 might not get the DEM anymore at first, but this is good to keep the resampling method at top of mind in the future.

yellowcap avatar Apr 01 '24 14:04 yellowcap

Closing as out of date, feel free to reopen if appropriate.

yellowcap avatar Jun 05 '24 10:06 yellowcap