ComenzarEmpieza gratis

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 ejercicio forma parte del curso

Working with Geospatial Data in Python

Ver curso

Instrucciones del ejercicio

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

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# 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 y ejecutar código