stac-layer icon indicating copy to clipboard operation
stac-layer copied to clipboard

Fall back to footprint when COG isn't georeferenced

Open m-mohr opened this issue 4 years ago • 9 comments

Originates from https://github.com/radiantearth/stac-browser/issues/101 and was written originally by @AsgerPetersen:

The Items in this demo catalog https://skraafotodistribution-stacfastapi.k8s-test-121.septima.dk/ have footprints, but their COGs are not georeferenced as they are not rectified.

It would be nice if the browser would fall back to the footprint in that case.

image

m-mohr avatar Oct 14 '21 10:10 m-mohr

I dug a little deeper and the issue is that I'm missing a try-catch in georaster which causes the promise to parse the GeoRaster to never complete when this error occurs. Here's a link to the line where I need to add a try/catch: https://github.com/GeoTIFF/georaster/blob/master/src/parseData.js#L83. When I manually throw the error, stac-layer works fine.

I'll fix georaster and this should fix the downstream issues.

DanielJDufour avatar Oct 14 '21 14:10 DanielJDufour

Sounds great, thanks. I thought this would be a new feature and not a bugfix :-)

m-mohr avatar Oct 14 '21 14:10 m-mohr

Small update. I tried to fix this in georaster with https://github.com/GeoTIFF/georaster/commit/93d6491394e623c6fe1189c4f2c85cba98288b3a#diff-5369190f55138dab912f4f97bca88335d0f783f50e14cda286672c7e5821963aR83, but it didn't work. The issue is that georaster uses old school promises and not async/await, so I have to update the code not just there, but everywhere else along the promise chain to make sure the error is sent all the way up (not to mention that the promise rejection is inside a web worker, so the error has to be sent as a message to the main thread).

I'm working on a massive upgrade to georaster at the moment (including using async/await), but that probably won't be complete for still a couple months. I've already sank 2 hours into doing a hotfix to georaster, so I'm not optimistic about this path.

That said, I think there is an easier solution. I can just fetch the first 1k bytes and then check if the projection information is in there using geotiff.js or is-cog. If it's not, don't run parseGeoraster. I'll keep you updated.

DanielJDufour avatar Oct 14 '21 16:10 DanielJDufour

This will hopefully be addressed by https://github.com/stac-utils/stac-layer/pull/13 whereby if the georaster doesn't finish parsing after 5 seconds, it will move onto the next load option. I know it's not perfect, but should hopefully be sufficient until the next major release of georaster (hopefully by the end of the year).

DanielJDufour avatar Oct 27 '21 03:10 DanielJDufour

The original data is not available anymore, is there a successor URL/file we could test with @AsgerPetersen?

m-mohr avatar Mar 02 '23 15:03 m-mohr

This is the production version of the STAC api: https://api.dataforsyningen.dk/skraafoto_api/v1.0/?token=6f27c9754e42e3ded6042f804203579b

The API and its data are free and open but requires a user token. I have created a token specifically for this issue, but I cannot guarantee for how long the token will survive. Ping me again if it stops working.

AsgerPetersen avatar Mar 03 '23 10:03 AsgerPetersen

@AsgerPetersen Thanks a lot! Would you be okay with us downloading one of the GeoTiffs and (maybe after cropping), putting it with attribution (CC-BY 4.0) on https://github.com/GeoTIFF/test-data so that we avoid the token issue?

m-mohr avatar Mar 03 '23 12:03 m-mohr

According to the license link on the items (https://dataforsyningen.dk/Vilkaar) CC-BY 4.0 is allowed. The name of the creator is "Styrelsen for Dataforsyning og Infrastruktur"

AsgerPetersen avatar Mar 03 '23 13:03 AsgerPetersen

@AsgerPetersen Thank you!

@DanielJDufour If you think this is a good idea, could you take care of this? I don't think I can push to the test-data repo...

m-mohr avatar Mar 03 '23 13:03 m-mohr