I'm using python library GeoPandas which bundles Shapely, Fiona, PyProj and others. I'm importing a countries shapefile to project lat/lon coordinates from a Google Maps API to find the country that contains that location.
Problem is the country returned is not correct. The code below looks up a location in Cincinnati, OH, and the lookup returns Antarctica. Both my point data and country data appear to be using decimal latitude and longitude. What am I doing wrong?
Here the code:
import geopandas as gpd
from shapely.geometry import Point
# Cincinnati, OH using Google Maps
pt = Point(39.0972618663624, -84.5065838098526)
# countries shapefile from
# http://thematicmapping.org/downloads/world_borders.php
data = gpd.read_file('TM_WORLD_BORDERS_SIMPL-0.3.shp')
# loop over countries
for index, row in data.iterrows():
poly = row['geometry']
if poly.contains(pt):
print row # prints Antarctica