1

I have no knowledge or experience related to geosciences. I have a list of addresses from Rio and I used GeoPy's geocoding (the Google API) to find the coordinates associated with these addresses. This gives me a geometry of (latitude, longitude, altitude) trios. Then, I construct a GeoDataFrame with this combined information. I then use .set_crs(epsg=4326,inplace=True) to inform the lat-lon crs.

However, when I try to plot this data, or use the .explore() method to see the interactive map, the results are way off: enter image description here

When I reverse the latitude and longitude coordinates, it works as I would expect enter image description here

Why is GeoPandas seemingly reading the coordinates in the incorrect order?

Edit

A MRE goes as follows:

from geopy.geocoders import GoogleV3

geolocator = GoogleV3(api_key=API_KEY)
# Example using a street from Rio
response = geolocator.geocode(query = 'RUA COLIDER, RJ')

response
Location(Rua Colider - Campo Grande, Rio de Janeiro - RJ, 23047-390, Brazil, (-22.9257627, -43.5650209, 0.0))
# Creating the GeoDataFrame
gdf = gpd.GeoDataFrame(gdf, geometry = [Point(response.point.latitude, response.point.longitude)])
gdf.set_crs(epsg=4326, inplace=True)
gdf.explore()

enter image description here

Where it actually is (from https://www.gps-coordinates.net/):

enter image description here

0

1 Answer 1

3

You're passing the coordinates in the wrong order, shapely uses GIS axis order Point(x,y) so use:

Point(response.point.longitude, response.point.latitude)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.