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

Add kdtree-based nearest point method #243

Closed
sandorkertesz opened this issue Oct 20, 2023 · 0 comments · Fixed by #244
Closed

Add kdtree-based nearest point method #243

sandorkertesz opened this issue Oct 20, 2023 · 0 comments · Fixed by #244
Assignees
Labels
enhancement New feature or request

Comments

@sandorkertesz
Copy link
Collaborator

sandorkertesz commented Oct 20, 2023

Working examples:

>>> from earthkit.data import from_source
>>> from earthkit.data.geo import nearest_point_kdtree
>>> ds = from_source("file", "tests/data/t_time_series.grib")
>>> latlon = ds.to_latlon()
>>> lat = latlon["lat"]
>>> lon = latlon["lon"]
>>> p_ref = (51.45, -0.97)
>>> nearest_point_kdtree(p_ref, (lat, lon))
(array([12]), array([952662.46605954]))
>>> from earthkit.data import from_source
>>> from earthkit.data.geo import GeoKDTree
>>> ds = from_source("file", "tests/data/t_time_series.grib")
>>> latlon = ds.to_latlon()
>>> lat = latlon["lat"]
>>> lon = latlon["lon"]
>>> p_ref = (51.45, -0.97)
>>> tree = GeoKDTree(lat, lon)
>>> tree.nearest_point(p_ref)
(array([12]), array([952662.46605954]))
@sandorkertesz sandorkertesz added the enhancement New feature or request label Oct 20, 2023
@sandorkertesz sandorkertesz self-assigned this Oct 20, 2023
@sandorkertesz sandorkertesz linked a pull request Oct 23, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant