Contextily basemap is blank with point GeoDataFrame

1.2k views Asked by At

I have a dataframe of individual addresses with lat/long that I converted to a GeoPandas dataframe. I set the projection to the Contextily EPSG:3857 projection.

df = gpd.GeoDataFrame(df_vf, geometry=gpd.points_from_xy(df_vf.longitude,df_vf.latitude), crs='EPSG:3857')
df
    file_state  geometry
4588464 GA  POINT (-84.20550 33.96780)
4668958 GA  POINT (-81.21680 32.29210)
6530022 GA  POINT (-84.98100 34.88710)
1936043 GA  POINT (-84.42160 34.03330)
5649637 GA  POINT (-83.83120 32.62850)

All of these individuals are in the state of Georgia, so these points look correct to me. I confirmed with df.crs that the EPSG is 3857. I'm trying to plot the points on a contextily plot, using:

ax = df.plot(figsize=(10,10), alpha=0.5, edgecolor='k')
cx.add_basemap(ax, crs=df.crs.to_string(), zoom = 10)

Here is the resulting blank plot

I tried to follow the advice of other people who have had similar issues: Github issue, Stack Overflow issue by changing the source and zoom level but that hasn't resolved it.

1

There are 1 answers

2
martinfleis On BEST ANSWER

The CRS of your geometries is not 3857 but 4326. Coordinates are clearly in degrees.

df = gpd.GeoDataFrame(df_vf, 
                      geometry=gpd.points_from_xy(df_vf.longitude,df_vf.latitude), 
                      crs='EPSG:4326')

ax = df.plot(figsize=(10,10), alpha=0.5, edgecolor='k')
cx.add_basemap(ax, crs=df.crs, zoom = 10)