GeoTIFF / georaster

Wrapper around Georeferenced Rasters like GeoTIFF and soon JPG and PNG that provides a standard interface
Apache License 2.0
81 stars 32 forks source link

Is it possible to combine the values from two rasters? I.e. raster math client side #73

Open staffordsmith83 opened 1 year ago

staffordsmith83 commented 1 year ago

Is your feature request related to a problem? Please describe. This feature request is not related to a problem.

Describe the solution you'd like We would like to be able to perform things like image differencing client side - subtracting the pixel values of one raster from another, and displaying the results.

Describe alternatives you've considered We have tried implementing the server side.

Additional context We are also using georaster-layer-for-leaflet, and are very grateful for this awesome project.

DanielJDufour commented 1 year ago

Hi, @staffordsmith83 . Thanks for your great question! If you are looking to do this for georaster-layer-for-leaflet, I'd recommend checking out this example: https://github.com/GeoTIFF/georaster-layer-for-leaflet-example/blob/master/examples/separated.html. GeoRasterLayer supports multiple georasters and does the band arithmetic on the fly, which means it is relatively fast, but also doesn't produce an output that one could download.

If you are looking to do this and produce a high-res output that operates on the true values (not overview values) and can be downloaded, you might have to combine the data in JavaScript into an "in-memory simple GeoRaster object" and then pass that to GeoBlaze's bandArithmetic function.

Coincidentally, the issue popped up on the GeoBlaze issues just the other day! https://github.com/GeoTIFF/geoblaze/issues/195#issuecomment-1446381503

It's my middle term goal to add multi-raster support to geowarp or a new library that uses it, but unfortunately this cleaner solution is still a year or so away.

Let me know if you have any more questions!

staffordsmith83 commented 1 year ago

Hi @DanielJDufour thanks so much for your detailed reply and thanks again for your work!

DanielJDufour commented 1 year ago

Hi, @staffordsmith83 . If the georasters are small (i.e. can read all values into memory), this notebook also shows how to merge/stack them into one georaster. I'd like to work on a better solution in the long term, but might take some time before that happens. (because I'm consider API changes for georaster for the next major version while trying not to break any pre-existing code). https://observablehq.com/d/723dc08141af20d0

staffordsmith83 commented 1 year ago

Thanks for this Daniel, we dont really need to be able to download, and operating on the overviews should work best for us I think. Thanks for sharing the workbook having a look at that too. Thanks!