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

Proposal: reverse geocoder #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nucccc
Copy link

@nucccc nucccc commented Aug 25, 2024

I saw #2 and this is one of the few local geocoding libraries, so I had the need to implement a reverse geocoder based on it. I'm proposing a way to execute reverse geocoding from the geo_data variable inside Geocode.

Root idea is to fit a KDTree (imported from scikit-learn) on the longitudes and latitudes, so that a new latitude and longitude pair can be queried, in order to obtain the index of the nearest location.

An example of use of the branch:

from geocode.geocode import Geocode
gc = Geocode()
gc.load()

rgc = gc.build_reverse_geocoder()
rgc.nearest_geodata(11.20, 43.75)

# ['Scandicci', 'Scandicci', 'IT', 11.18794, 43.75423, '3166988', 'place', 44951]

basically a class ReverseGeocoder is returned by Geocode and that class holds the kdtree to query the nearest points.

I don't know if the PR fits your idea of the project.
In case also the way in which it's implemented or the function names could be modified. Docs could be added to this PR if it makes sense.

Let me know if it is of interest for you!

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 this pull request may close these issues.

1 participant