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

return indices as CartesianIndex #115

Closed
alex-s-gardner opened this issue Dec 16, 2022 · 3 comments · Fixed by #126
Closed

return indices as CartesianIndex #115

alex-s-gardner opened this issue Dec 16, 2022 · 3 comments · Fixed by #126

Comments

@alex-s-gardner
Copy link
Contributor

alex-s-gardner commented Dec 16, 2022

If indices were returned as CartesianIndex then they can be used to directly index info a geoarray when dealing with Vector of points

@alex-s-gardner
Copy link
Contributor Author

This is what I'm doing now:

find indices of points

ind = indices.(Ref(ga0), xy);

extract values

ind = [CartesianIndex((ij[1], ij[2])) for ij in ind]
val = ga0[ind]

@evetion
Copy link
Owner

evetion commented Dec 17, 2022

I think it's a fair point that we should accept and return CartesianIndices, although it would be breaking. Note you can rewrite your code to:

CartesianIndex.(Tuple.(indices.(Ref(ga), xy)))

And you can actually index into the GeoArray directly with floating point numbers: getindex.(Ref(ga), SVector{2}.(xy)).

@evetion evetion mentioned this issue Mar 27, 2023
2 tasks
@evetion
Copy link
Owner

evetion commented Mar 31, 2023

In GeoArrays 0.8, indices(::GeoArray, x, y) are now returned as CartesianIndex.

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

Successfully merging a pull request may close this issue.

2 participants