GeoTIFF/georaster-layer-for-leaflet

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

john-a-m opened this issue · 4 comments

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?

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.

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.

@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

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.