azavea / loam

Javascript wrapper for GDAL in the browser
Apache License 2.0
218 stars 16 forks source link

Does this library support GDALGetRasterStatistics exposed in gdal-js ? #81

Closed shaunakv1 closed 1 year ago

shaunakv1 commented 3 years ago

Hello , first up thanks for awesome work on this wrapper. I am scoping this out for potentially using it for doing raster statistics calculation. Sorry for lack of any code to ask question with. But I am wondering if it's possible to use GDALGetRasterStatistics function for a GeoTIFF raster. It seems the driver supports this as mentioned in the readme here:

https://github.com/ddohler/gdal-js

ddohler commented 3 years ago

@shaunakv1 Thanks for asking! Currently none of the GDAL functions that rely on GDALRasterBand are wrapped; that's due to a lack of time, primarily -- I'm pretty sure I know how I'd design the interface for such a feature, but haven't gotten to it yet. If you've got the time and inclination to put together a PR, I'd be happy to assist, though I understand that's not an option for many people. Conservatively, I expect that adding wrappers for the raster methods would take 12-18 hours for me, and perhaps twice as long for someone who's less familiar with the project. Alternatively, using gdal-js directly may be a option, although I suspect that for anything moderately complex you'd be likely to save time by adding functionality to Loam (that's what I do if I need something that gdal-js supports, but Loam does not).

I hope that helps! I'll keep this issue open and try to get to this feature as soon as I can!

shaunakv1 commented 3 years ago

@ddohler Thank you for a prompt response! I totally understand the work that goes in and am happy to wait. We have current system and this is potentially for future enhancements.

In the mean time I will try and pull this down to see if I can help along. Is there any contribution guide yet that might ease me into this project? or may be even something tagged for good first issue? I am happy to give it a shot, but I am skittish in making commitments for new work atm.

ddohler commented 3 years ago

Thanks for offering to help! I took a quick skim over the issue backlog and I don't see anything that looks immediately applicable to this at the moment, unfortunately. This issue is a good example of adding a new wrapper method, although I think the raster band case will be more complex because decisions will need to be made about how to model and handle raster bands within Loam. So I guess that would be a good starting place. Do you have preferences between either of these two interfaces:

loam.open(blob).then(ds => ds.getBand(1)).then(band => band.getStatistics());

or

loam.open(blob).then(ds => ds.statisticsForBand(1));

?

shaunakv1 commented 3 years ago

That 's a good question. Personally I would lean towards.

loam.open(blob).then(ds => ds.getBand(1)).then(band => band.getStatistics());

Reason being, for larger rasters I am assuming the above will give users more control to lazy load bands. In the second interface the promise will return all bands in the rasters, which is okay for smaller files but not so much for larger ones.

delebash commented 2 years ago

+1 For adding GDALRasterBand