-
Notifications
You must be signed in to change notification settings - Fork 37
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
Better extract #565
Better extract #565
Conversation
Co-authored-by: Tiem van der Deure <[email protected]>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #565 +/- ##
==========================================
- Coverage 80.61% 80.60% -0.02%
==========================================
Files 57 57
Lines 4127 4212 +85
==========================================
+ Hits 3327 3395 +68
- Misses 800 817 +17 ☔ View full report in Codecov by Sentry. |
@visr have you seen this anywhere else? we are getting failures in GDAL.jl
See here: https://github.com/rafaqz/Rasters.jl/actions/runs/6697436007/job/18560020921#step:5:949 Linux tests are passing fine. |
Odd that this only happens on MacOS. I haven't seen this error before. |
src/methods/extract.jl
Outdated
# use `extract` to get values for all layers at each observation point. | ||
# We `collect` to get a `Vector` from the lazy iterator. | ||
collect(extract(st, pnts)) | ||
collect(extract(st, pnts; skipmissing=true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No point in using collect on a Vector, right?
# use `extract` to get values for all layers at each observation point. | |
# We `collect` to get a `Vector` from the lazy iterator. | |
collect(extract(st, pnts)) | |
collect(extract(st, pnts; skipmissing=true)) | |
# use `extract` to get values for all layers at each observation point. | |
extract(st, pnts; skipmissing=true) |
Handling missings seems to work wonderfully when giving E.g. using Rasters
myrast = Raster(rand(X(10), Y(10)))
extract(myrast, ((X = missing , Y = missing), (X= 1, Y = 10))) # work but return Vector{Any}
extract(myrast, ((X= 1, Y = 10), (X = missing , Y = missing))) # errors
extract(myrast, ((X = missing , Y = 10),)) # Gives a StackOverflowError! Or is this also what you mean by mixed geometries? Any point data that comes from a table and has some missing coordinates will look like this. Maybe a solution could be to use a function that also skips geoms that contain I'll have time to look at this more tomorrow. |
We should force the return type to be at least We are not actually using |
@tiemvanderdeure handling this isn't possible because your points with missing coordinates are not valid GeoInterface geometries: extract(myrast, ((X = missing , Y = missing), (X= 1, Y = 10))) And to throw a better error there we need to disallow arbitrary objects like you tuple of points, its limited to an |
Co-authored-by: Tiem van der Deure <[email protected]>
Co-authored-by: Tiem van der Deure <[email protected]>
This PR mostly adds new keywords to
extract
@tiemvanderdeure feel like reviewing this thing?
I made it return a vector - this isn't breaking as its still an iterable and we never promised the exact type or iterable.
I took the opportunity to polish the (pretty basic) implementation a little. As well as the new keywords,
extract
now properly handles flattening multiple polygons/feature collections/nested vectors of geoms so you always get a single "table" return value, and handles empty or all-missing inputs. The only known bug is mixed points and geometries in one vector or will fail. This is noted in the doc, and its kinda rare and not worth the effort right now.Also once I squash the commits together you wont just be on that one empty commit but the whole thing, its just to get your name on the list.