hongfaqiu / TIFFImageryProvider

Load GeoTIFF/COG(Cloud optimized GeoTIFF) on Cesium
https://tiff-imagery-provider.opendde.com/?panel=layer
MIT License
49 stars 10 forks source link

Unnecessary Resampling leading to poor pixel positioning #30

Open staffordsmith83 opened 1 week ago

staffordsmith83 commented 1 week ago

Dear Hongfaqiou,

there seems to be an issue with how TIFFImageryProvider maps the tiff values to the canvas. This occurs even when re-projection is not needed, e.g. for cogs in EPSG:4326 and EPSG:3857.

Using this Climate Data cog as an example (it is in EPSG:4326): https://nex-gddp-cmip6-cog.s3-us-west-2.amazonaws.com/daily/GFDL-CM4/ssp585/r1i1p1f1/pr/pr_day_GFDL-CM4_ssp585_r1i1p1f1_gr1_2015_01_25.tif

The data should look like this: image

But TIFFImageryProvider renders it like this: image

Note the following:

Note in a more zoomed in example, how the pixels are clearly not square. This is TIFFImageryProvider in TerriaJS: image

This is TIFFImageryProvider in your online demo: image

Whereas the tru data is square pixels (shown in QGIS): image

Please note, to be able to see what is happening at the pixel level we have changed the Cesium settings for _defaultMagnificationFilter and _defaultMinificationFilter to remove the blurring: https://github.com/TerriaJS/terriajs/blob/13fa4cfaabecdc82dff749836a1dcef602b0a1ae/lib/Models/Catalog/CatalogItems/CogCatalogItem.ts#L140-L141

If you like, we have put more details on the perceived error in out PR here: https://github.com/TerriaJS/terriajs/pull/7209

hongfaqiu commented 1 week ago

@staffordsmith83 I'm glad to see you continue to support TIFF in Terriajs. This issue is the same as #18 #22 , and I've been quite busy lately. I'll try to fix this issue next week, which seems to be related to resampling

staffordsmith83 commented 1 week ago

Thats great, thanks @hongfaqiu, @nf-s watch this ticket