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.
Это упражнение является частью курса
Working with Geospatial Data in Python
Инструкции к упражнению
- Check what kind of object
districtsis with thetype()function. - Access the
geometryattribute of thedistrictsGeoDataFrame and print the type of this object. - Show the first 5 rows of the geometry.
- Inspect the area of the districts's geometries.
Интерактивное практическое упражнение
Попробуйте выполнить это упражнение, дополнив этот пример кода.
# 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.____)