I posted my question in stackoverflow previously, howeverI think this site is a better place to find some clues (this is my first project with spacial data).
I need to insert some coordinates from a dataframe to a NYC map. For this task I am using geopandas. This is my code:
gdf = gpd.GeoDataFrame(DF, geometry=gpd.points_from_xy(DF.pickup_longitude, DF.pickup_latitude))
I got the following:
Unnamed: 0 DOLocationID ... time geometry
0 0 NaN ... 0.380278 POINT (-74.01576 40.71555)
1 1 NaN ... 0.390833 POINT (-73.98205 40.76276)
2 2 NaN ... 0.350556 POINT (-73.97941 40.75543)
3 3 NaN ... 0.503056 POINT (-73.77679 40.64509)
4 4 NaN ... 0.618333 POINT (-73.78806 40.64167)
[5 rows x 31 columns]
Then I create the map using this code:
First
gdf.crs = 4326
gdf = gdf.to_crs(3857)
Then:
df = gpd.read_file(gpd.datasets.get_path('nybb'))
df = df.to_crs(epsg=3857)
ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
ctx.add_basemap(ax)
As you see, NYC becomes into the entire continent.
My question is: how do I plot the geometry column into the map accurately?