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

Potentially unsupported geometry? #191

Open
chrispahm opened this issue Aug 9, 2022 · 1 comment
Open

Potentially unsupported geometry? #191

chrispahm opened this issue Aug 9, 2022 · 1 comment

Comments

@chrispahm
Copy link

Describe the bug
When trying to calculate means for many (thousand) polygons, I frequently receive the "No Values were found in the given geometry" error. However, the raster definitely covers the given geometry and has values in it (checked using QGIS → Zonal Statistics).
Also, the mean calculation works when I just pass the geometries bboxes.
Could it be that the type of polygon, e.g. "MultiPolygons" or concave polygons are not supported by geoblaze?

To Reproduce
See the following Observable notebook to reproduce:
https://observablehq.com/@chrispahm/geoblaze-unsupported-geometry-type

Expected behavior
The mean method should return the same mean as QGIS zonal statistics.

@DanielJDufour
Copy link
Member

DanielJDufour commented Mar 5, 2023

Hi, @chrispahm . I'm very sorry I missed this. I think the issue is that the algorithm that geoblaze uses dufour-peyton-intersection, was originally built for use cases where the geometries were larger in size than the pixels. However, this is not always the case as we have seen with your dataset.

The most immediate solution would be to see if you could resample your tiff to a higher resolution (it's technically not going to be higher "resolution" in some sense, but will have a lot more pixels).

Alternatively, you could calculate the size of the bounding box of the geometry using https://turfjs.org/ and if the size of the bounding box is smaller than the size of a pixel, calculate the centroid and run geoblaze.identify(georaster, centroid). After all, the mean of one value is equal to that one value.

Long term, it would be great to make geoblaze smarter to more gracefully handle these use cases. I know for a fact is is quite possible to solve this issue as we did as much with geowarp (https://github.com/DanielJDufour/geowarp/blob/main/geowarp.js#L779). I'm light on time at the moment, so a better solution will probably take a few months.

In the meantime, I'd love to keep this issue open as it is a very valid issue and I very much would like to see a solution for it.

Thank you very much for bringing this to our attention!

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