0

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 Answers1

3

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)
martinfleis
  • 7,124
  • 2
  • 22
  • 30
  • Thank you, this solved my problem. I thought I saw that Contextily required the 3857 CRS, but I just read up on the differences between 3857 and 4326 and I see now. – Adriana Rogers May 05 '21 at 15:27
  • 1
    Contextily by default uses 3857 but you can reproject tiles by passing specific CRS as you do in `add_basemap`. – martinfleis May 05 '21 at 16:52