Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a maximum number of bands a COG will support? #146

Open
john-a-m opened this issue Apr 14, 2024 · 4 comments
Open

Is there a maximum number of bands a COG will support? #146

john-a-m opened this issue Apr 14, 2024 · 4 comments

Comments

@john-a-m
Copy link

Is your feature request related to a problem? Please describe.
I've tried using multiband COGs not more than 20mb. With 24 bands the georaster-layer-for-leaflet plugin is very slow, the original number of bands was 144 (totally unusable). The raster size is approximately 2000x850. The data are also very sparse (~95% of the values in the rasters are 0s).

Describe the solution you'd like
A way to configure the plugin to support a large number of bands, approximately 100-200. My issue may also stem from not understanding the COG format well enough.

Describe alternatives you've considered
Could my issue be solved by creating external overview files? I see in some of the examples where the bands are stored in individual files, is loading 100 separate files reasonable from a performance perspective?

@DanielJDufour
Copy link
Member

DanielJDufour commented Apr 20, 2024

It's possible the performance is related to the way georaster is bundling an older version of geotiff.js. Would you be able to see the workaround described here and let me know if that works for you?
GeoTIFF/geoblaze#226 (comment)

Long term, I hope to publish a new version of georaster that fixes this issue, but that may take some time because we're in the middle of a re-write.

@john-a-m
Copy link
Author

I came to the same conclusion, my workaround right now is to download the data directly (gzip compresses it well) and construct the georasters manually as described here (https://github.com/GeoTIFF/georaster?tab=readme-ov-file#load-from-simple-object-on-front-end). Here is the metadata I'm supplying.

const sizeDegrees = 0.02906874;
const projection = 4326;
const xmin = -124.725839;
const xmax = -66.949895;
const ymin = 24.498131;
const ymax = 49.384358;
const pixelWidth = sizeDegrees;
const pixelHeight = sizeDegrees;
const metadata = { projection, xmin, xmax, ymin, ymax, pixelWidth, pixelHeight };

However I've run into another issue, with a raster 2000x850 that means there are 1.7m unique tiles. Even when I set the resolution to 8 I still have a good deal of lag when panning/zooming. Is there someway to change the way I create the rasters so they work better with GeoRasterLayer? I also tried extending GridLayer the way this plugin does and found out that createTile creates a new div/canvas for every cell 🤮.

As part of your rewrite are you planning to make it so that there is only a single canvas element? If not I think I'll give that a try, if so maybe I'll wait. In any case good luck with your endeavor.

@DanielJDufour
Copy link
Member

@john-a-m , could you try the experimental pre-release version of georaster-layer-for-leaflet and let me know if that improves the performance for you?!

npm install georaster-layer-for-leaflet@next

@john-a-m
Copy link
Author

It's been a while since I've used nvm/node/npm, here's what I did. I created an empty project and ran npm install georaster-layer-for-leaflet@next everything seemed to install correctly. I looked at scripts in package.json and decided to copy georaster-layer-for-leaflet.min.js from the dist directory to the server. Anecdotally it does seem to run slightly faster, although I did notice there seems to be some "redraw artifacts".
redraw_artifacts

For the resolution/zoom in that picture I would expect the little pixels to be resampled into the bigger pixels. Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants