geotiffjs / geotiff.js

geotiff.js is a small library to parse TIFF files for visualization or analysis. It is written in pure JavaScript, and is usable in both the browser and node.js applications.
https://geotiffjs.github.io/
MIT License
841 stars 175 forks source link

wide margin outside the image #223

Closed simod closed 2 years ago

simod commented 3 years ago

I'm generating 256 colors palette COGs but they display a very wide margin outside the extent of them. The color of the margin is taken from the value of the first element of the palette (0) and it appears outside beyond the noData, where there is no information. Seems like the part of the tiles where there's no image are set to 0 and colored accordingly. Do you have any hint? Thanks in advance

constantinius commented 3 years ago

Can you show me how you are reading the data from the TIFF?

I think, there will be a default value assumed, for reading outside of the image, resulting in wrong colors.

simod commented 3 years ago

@constantinius thanks for the quick reply. An example here on the cog explorer. https://geotiffjs.github.io/cog-explorer/#long=48.336&lat=-17.517&zoom=9&scene=https://cems-rm-viewer.s3.eu-central-1.amazonaws.com/EMSR424/AOI02/DEL/COG/EMSR424_AOI02_DEL_PRODUCT_SENTINEL2_20200131_0704_ORTHO.tif&bands=&pipeline=

constantinius commented 3 years ago

Ah, I see. We actually had this in a couple of other images in COG-Explorer. This may be due to overviews. I'll investigate.

simod commented 3 years ago

Indeed is related to ovrs. I tried to generate them at 512 size and, at small zoom levels, the green is much bigger. I still have the feeling is due to the cog generation, but I'm fighting for days now without success... :)

thanks

simod commented 3 years ago

@constantinius I tried to generate the image without the overviews, the margin is a lot less but some is still there, like the filling of the tiles is also using the value 0. I'd suppose the overviews are just filled using the same approach. But I'm not sure where to look in the code to find where that happens.

simod commented 3 years ago

@constantinius hi, I was wondering if you had the chance to look at this, or could you please point me to the code part that handles it? Thanks a lot!

constantinius commented 3 years ago

Hi @simod

Sorry, was on vacation last week. I'll have a look as soon as possible (working through backlog now)

simod commented 3 years ago

@constantinius sorry to come back to this again. Though I'd like to find a way to avoid the margin in my application as is very ugly... for what I could get it seems that whatever is outside of the image in tiles and overviews is put to 0, while it should probably put to the no-data value of the image. I can try to dive into the code if you are busy but I'd appreciate some pointer :) or maybe is something that I can fix at COG generation level that I don't see...
Thanks a lot in advance. ps, here a link to my app that has the same symptoms of the cog explorer. https://activations.emergency.copernicus.eu/#EMSR424.

tschaub commented 2 years ago

I'm guessing this may be fixed by #248.

@simod, let me know if you are able to test your application with the changes in my branch.

constantinius commented 2 years ago

@simod @tschaub

I think with #248 we can close this issue, right?

simod commented 2 years ago

@constantinius I couldn't test it but looking at the description and the code I think is a great work that will solve it. I'm +1 for closing, in case I'll come back.

Thanks @tschaub !