Parry Chen
Parry Chen

Reputation: 29

Trying to Add Basemap Background in with GeoPandas, Background is Displaying Incorrectly

I'm fairly new to Python, so sorry if there's a simple thing I'm missing. I've tried to troubleshoot ):

I'm trying to add basemap to geopandas, here is the code:

dropoff = gpd.GeoDataFrame(dataset, geometry=gpd.points_from_xy(dataset["dropoff_lon"],dataset["dropoff_lat"]))
dropoff = dropoff.set_crs(epsg=3857, allow_override=True)
ax = dropoff.plot(figsize = (10,10))
ctx.add_basemap(ax, zoom = 0)

the image keeps showing as this, it's supposed to display a map of NYC in the background:

enter image description here

Upvotes: 0

Views: 821

Answers (1)

Parry Chen
Parry Chen

Reputation: 29

I figure out the answer.

crs needed to be referenced in the basemap. Like this:

ctx.add_basemap(ax, crs='EPSG:4326', zoom = 15)

Upvotes: 1

Related Questions