Session Ready
Exercise

The Paris restaurants as a GeoDataFrame

In the first coding exercise of this chapter, we imported the locations of the restaurants in Paris from a csv file. To enable the geospatial functionality of GeoPandas, we want to convert the pandas DataFrame to a GeoDataFrame. This can be done with the GeoDataFrame() constructor and the geopandas.points_from_xy() function, and is done for you.

Now we have a GeoDataFrame, all spatial functionality becomes available, such as plotting the geometries. In this exercise we will make the same figure as in the first exercise with the restaurants dataset, but now using the GeoDataFrame's plot() method.

Pandas has been imported as pd, GeoPandas as geopandas and matplotlib's pyplot functionality as plt.

Instructions
100 XP
  • Inspect the first rows of the restaurants GeoDataFrame.
  • Plot it with the plot() method of the GeoDataFrame. The return value is a matplotlib axes object: call this ax.
  • Again, make sure to set the marker size equal to 1.
  • Add a basemap layer using contextily.