Get startedGet started for free

Explore the Paris districts (II)

In the previous exercise, we used the customized plot() method of the GeoDataFrame, which produces a simple visualization of the geometries in the dataset. The GeoDataFrame and GeoSeries objects can be seen as "spatial-aware" DataFrame and Series objects, and compared to their pandas counterparts, they expose additional spatial-specific methods and attributes.

The .geometry attribute of a GeoDataFrame always returns the column with the geometry objects as a GeoSeries, whichever the actual name of the column (in the default case it will also be called 'geometry').

Another example of extra spatial functionality is the area attribute, giving the area of the polygons.

GeoPandas has been imported as geopandas and the districts dataset is available as the districts variable.

This exercise is part of the course

Working with Geospatial Data in Python

View Course

Exercise instructions

  • Check what kind of object districts is with the type() function.
  • Access the geometry attribute of the districts GeoDataFrame and print the type of this object.
  • Show the first 5 rows of the geometry.
  • Inspect the area of the districts's geometries.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Check what kind of object districts is
print(type(____))

# Check the type of the geometry attribute
print(____)

# Inspect the first rows of the geometry
print(districts.____)

# Inspect the area of the districts
print(districts.____)
Edit and Run Code