ComeçarComece de graça

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.

Este exercício faz parte do curso

Working with Geospatial Data in Python

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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.____)
Editar e executar o código