I am trying to use geopandas to plot some info over a map. The first thing that I do is to upload a shape file of New York City:
nyc_boroughBoundaries = geopandas.read_file ("nybb_19b2")
This is returning a geodataframe:
type (nyc_boroughBoundaries)
geopandas.geodataframe.GeoDataFrame
And has a geometry column:
geometry
(POLYGON ((1012821.805786133 229228.2645874023...
(POLYGON ((970217.0223999023 145643.3322143555...
(POLYGON ((1029606.076599121 156073.8142089844...
I am repeating the same process to load some information about new constructions in NYC
geo_df_NB_2018["Coordinates"]
POINT (40.62722 -73.969634)
POINT (40.764575 -73.955421)
POINT (40.525584 -74.166414)
POINT (40.742845 -73.89083100000001)
POINT (40.679859 -73.93992
Then I am trying to plot both geodataframes in one single map doing the following:
fig, ax = plt.subplots (figsize = (15,15))
geo_df_NB_2018.plot(ax = ax, alpha = 0.7, color = "pink")
nyc_boroughBoundaries.plot(ax = ax)
However, they are being displayed in different parts of the figure.
Thanks!
You have different projections. They need to be the same to be plotted together. Look at your coordinates, they are clearly different. Moreover, as @steven pointed out, you have switched latitude and longitude. Fix that first and then reproject:
# convert CRS to the same as nyc_boroughBoundaries has
geo_df_NB_2018 = geo_df_NB_2018.to_crs(nyc_boroughBoundaries.crs)
fig, ax = plt.subplots(figsize=(15, 15))
geo_df_NB_2018.plot(ax=ax, alpha=0.7, color="pink")
nyc_boroughBoundaries.plot(ax=ax)