Simply reverse the order of the coordinates of the shapefile
import fiona
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="me", timeout=10)
redshape = fiona.open("points_geopy.shp")
# coordinates of the first feature (x,y = long,lat)
redshape[0]['geometry']['coordinates']
(-75.17009743393821, 39.9427660880249)
# iterate
for feature in redshape:
# reverse the coordinates x,y to y,x
coords = feature['geometry']['coordinates'][::-1]
location = geolocator.reverse(coords)
print(coords, location.address)
(39.9427660880249, -75.17009743393821) 723, South Chadwick Street, Hawthorne, South Philadelphia, Philadelphia, Philadelphia County, Pennsylvania, 19146, United States of America
(39.941477314134396, -75.166112027818) Tindley Temple United Methodist Church, 750, South Broad Street, Hawthorne, South Philadelphia, Philadelphia, Philadelphia County, Pennsylvania, 19146, United States of America
(39.9430681055253, -75.1634826347411) South 13th Street, Hawthorne, South Philadelphia, Philadelphia, Philadelphia County, Pennsylvania, 19148, United States of America
(39.9445279530865, -75.16772651013079) 1538, Naudain Street, Rittenhouse Square, Philadelphia, Philadelphia County, Pennsylvania, 19146, United States of America
...
With GeoPandas (use Fiona)
import geopandas as god
df = gpd.read_file("points_geopy.shp")
# reverse the coordinates x,y to y,x
df["geom"] = df.geometry.y.map(str) + ',' + df.geometry.x.map(str)
df["location"] = df.apply(lambda row:geolocator.reverse(row['geom']), axis=1)
df.head
geom geometry location
0 39.9427660880249,-75.17009743393821 POINT (-75.17010 39.94277) (723, South Chadwick Street, Hawthorne, South ...
1 39.941477314134396,-75.166112027818 POINT (-75.16611 39.94148) (Tindley Temple United Methodist Church, 750, ...
2 39.9430681055253,-75.1634826347411 POINT (-75.16348 39.94307) (South 13th Street, Hawthorne, South Philadelp...
3 39.9445279530865,-75.16772651013079 POINT (-75.16773 39.94453) (1538, Naudain Street, Rittenhouse Square, Phi...
4 39.9414861490123,-75.17186304554191 POINT (-75.17186 39.94149) (Marian Anderson Community Center, Catharine S...