索引和选择数据#
GeoPandas继承了该标准 pandas 索引/选择数据的方法。这包括基于标签的索引 loc
和基于整数位置的索引 iloc
,这两条都适用于 GeoSeries
和 GeoDataFrame
物体。有关索引/选择的更多信息,请参阅 pandas 文档。
除了标准之外, pandas 方法时,GeoPandas还提供基于坐标的索引 cx
索引器,使用边界框进行切片。中的几何图形 GeoSeries
或 GeoDataFrame
与边界框相交的元素将被返回。
使用 world
数据集,我们可以使用此功能快速选择边界延伸到南半球的所有国家/地区。
In [1]: world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
In [2]: southern_world = world.cx[:, :0]
In [3]: southern_world.plot(figsize=(10, 3));
