-
Notifications
You must be signed in to change notification settings - Fork 160
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
Incorrect Results in search
#57
Comments
Hello all, Thanks for the awesome work that you guys did here! I'm facing the same issue here. I Tested with a huge amount of coordinates, and some of them results wrongly. An important possible correlation: The data analysed is related to California as well. I'll show it below: Ploting every coordinate using plotly: import plotly.graph_objects as go
fig = go.Figure(
data = go.Scattergeo(
lon = dataset['longitude'],
lat = dataset['latitude'],
# text = dataset['description'],
mode = 'markers',
))
fig.update_layout(
title = 'Moradias por latitude e longitude',
geo_scope = 'usa'
).show() Creating a single column with both latitude and longitude and searching the state using search: import reverse_geocoder as rg
coordinates = [*zip(dataset['latitude'], dataset['longitude'])]
dataset.insert(0, 'coordinates', coordinates)
geo_infos = rg.search(tuple(dataset['coordinates']))
locations = list()
for item in geo_infos:
locations.append(item['admin1'])
dataset.insert(3, 'location', locations)
dataset['location'].unique() Result:
Filtering the 'Baja California' ocurrences: dataset[dataset['location'] == 'Baja California'] The location resulted by Google Maps: Some info regarding my setup:
|
As an additional information, I plotted in Google maps all points that was incorrectly classified. import os
import gmaps
gmaps.configure(api_key = os.environ['GOOGLE_MAPS_API_KEY'])
coord = dataset[dataset['location'] != 'California']['coordinates']
layer = gmaps.symbol_layer(coord, fill_color="green", stroke_color="green", scale=2)
fig = gmaps.figure(zoom_level = 5, center = [37.5706805, -117.6669101])
fig.add_layer(layer)
fig The result: The coordinates: (38.69, -119.78) |
The package labels coordinates by doing a nearest neighbors search to a set of labelled points. Since the points you provide are close to borders, it is likely that the closest reference point was in another state. This happens on the city level as well but it would be harder to notice. This is intrinsic feature of this reverese geocoder, using a different distance metric might help a bit but some errors will always happen. |
Hello all, I'm facing a similar issue too! However, it seems to occur even when using latitudes and longitudes that are nowhere near any international borders, as when I run the following script in a Jupyter Notebook, on Python version 3.7.4
Which creates a 2x4 array of latitudes and longitudes, which I then try to search with:
Gives me the following output:
Rerunning this will just give 'El Tarter, Canillo' as the correspondent location for all four map_centers. I'm not quite sure why after three successful initial calls of rg.search() it ends up breaking, but it does. None of these locations are near any borders, but rather it seems like rg.search isn't reading the latitudes and longitudes as I thought. Many thanks in advance! UPDATE: This error does not appear when running the above script in an editor (i.e. Spyder), so maybe it's a Jupyter related issue? |
Hello,
Thank you for the great work in publishing this package. I just came across the package and was trying it out when I ran into the following error, was hoping you could shed some light on this.
The result looks something like this:
If I am not wrong, this is indicating that this location is in Mexico. However, when you actually these coordinates in Google Maps, these coordinates are within USA.
The text was updated successfully, but these errors were encountered: