1. 主页
  2. 文档
  3. GeoPandas 0.12.2中文文档
  4. User Guide
  5. Merging Data(合并数据)

Merging Data(合并数据)

There are two ways to combine datasets in geopandas – attribute joins and spatial joins.

在 geopandas 中有两种组合数据集的方法——属性连接和空间连接。

In an attribute join, a GeoSeries or GeoDataFrame is combined with a regular pandas.Series or pandas.DataFrame based on a common variable. This is analogous to normal merging or joining in pandas.

在属性连接中,一个GeoSeries或GeoDataFrame与一个普通的pandas.Series或pandas.DataFrame基于一个共同的变量进行组合。这类似于pandas中的普通合并或连接。

In a Spatial Join, observations from two GeoSeries or GeoDataFrame are combined based on their spatial relationship to one another.

在空间连接中,来自两个GeoSeries或GeoDataFrame的观测数据根据它们之间的空间关系被结合起来。

In the following examples, we use these datasets:

在以下示例中,我们使用这些数据集:

In [1]: world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))

In [2]: cities = geopandas.read_file(geopandas.datasets.get_path('naturalearth_cities'))

# For attribute join
In [3]: country_shapes = world[['geometry', 'iso_a3']]

In [4]: country_names = world[['name', 'iso_a3']]

# For spatial join
In [5]: countries = world[['geometry', 'name']]

In [6]: countries = countries.rename(columns={'name':'country'})

文章

标签 , ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here