GeoPandas inherits the standard pandas methods for indexing/selecting data. This includes label based indexing with loc
and integer position based indexing with iloc
, which apply to both GeoSeries
and GeoDataFrame
objects. For more information on indexing/selecting, see the pandas documentation.
GeoPandas 继承了用于索引/选择数据的标准 pandas 方法。这包括使用 loc 的基于标签的索引和使用 iloc 的基于整数位置的索引,这适用于 GeoSeries 和 GeoDataFrame 对象。有关索引/选择的更多信息,请参阅 pandas 文档。
In addition to the standard pandas methods, GeoPandas also provides coordinate based indexing with the cx
indexer, which slices using a bounding box. Geometries in the GeoSeries
or GeoDataFrame
that intersect the bounding box will be returned.
除了标准的 pandas 方法外,GeoPandas 还使用 cx 索引器提供基于坐标的索引,该索引器使用边界框进行切片。 GeoSeries 或 GeoDataFrame 中与边界框相交的几何图形将被返回。
Using the world
dataset, we can use this functionality to quickly select all countries whose boundaries extend into the southern hemisphere.
使用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));