GeoTIFF / georaster-layer-for-leaflet

Display GeoTIFFs and soon other types of raster on your Leaflet Map
https://geotiff.github.io/georaster-layer-for-leaflet-example/
Apache License 2.0
296 stars 58 forks source link

Tiles misaligned when source raster not in native projection #128

Open staffordsmith83 opened 1 year ago

staffordsmith83 commented 1 year ago

Describe the bug When loading a cog that is in a non-native coordinate system, the cog is displayed in a way that individual tiles do not align well at the edges.

This is example is a public COG hosted at https://dea-public-data.s3.ap-southeast-2.amazonaws.com/derivative/ga_ls_tc_pc_cyear_3/1-0-0/x17/y37/2022--P1Y/ga_ls_tc_pc_cyear_3_x17y37_2022--P1Y_final_wet_pc_50.tif

It is in EPSG:3577

I am reprojecting as per the example code for georaster-layer-for-leaflet

To Reproduce Steps to reproduce the behavior:

  1. Load https://dea-public-data.s3.ap-southeast-2.amazonaws.com/derivative/ga_ls_tc_pc_cyear_3/1-0-0/x17/y37/2022--P1Y/ga_ls_tc_pc_cyear_3_x17y37_2022--P1Y_final_wet_pc_50.tif as a Georaster layer
  2. See that the tiles do not align

Expected behavior I would expect the tiles to align at the edges

Screenshots The cog overlaid on leaflet showing the misalignment:

image

Desktop (please complete the following information):

Additional context

If I reproject the cog to EPSG:4326, then the tiles align, so I believe this is due to how data is reprojected on the fly. I reprojected using command gdalwarp -t_srs EPSG:4326 -dstnodata -9999 ga_ls_tc_pc_cyear_3_x17y37_2022--P1Y_final_wet_pc_50.tif ga_ls_tc_pc_cyear_3_x17y37_2022--P1Y_final_wet_pc_50_4326.tif

I will leave the reprojeted cog file here for testing @DanielJDufour if that is helpful: https://stafs-cogs.s3.ap-southeast-2.amazonaws.com/ga_ls_tc_pc_cyear_3_x17y37_2022--P1Y_final_wet_pc_50_4326.tif

When reprojected to 4326:

image

Thankyou so much @DanielJDufour for the awesome helpful library!

jcphill commented 1 year ago

This is likely a duplicate of #77.