创建 GeoDataFrame 并检查几何数据
来看看 Nashville 的服务区分布。服务区 shapefile 的路径已存入变量 shapefile_path。
本练习是课程的一部分
在 Python 中可视化地理空间数据
练习说明
- 使用常见别名
gpd导入geopandas。 - 用
geopandas读取服务区的 shapefile,并使用head()方法查看前 5 行。 - 打印首行(行名为 '0')的几何字段,查看其中的数据。为此,您将把
service_district.loc[0, 'geometry']传给print()函数。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Import geopandas
import ____ as ____
# Read in the services district shapefile and look at the first few rows.
service_district = gpd.____(shapefile_path)
print(service_district.____())
# Print the contents of the service districts geometry in the first row
print(service_district.loc[0, '____'])