有哪些可用的 geopandas 数据集(地图)?

33

我刚刚创建了一个非常简单的geopandas示例(请参见下文)。它可以工作,但我注意到对我来说很重要的是能够拥有自定义的世界部分。有时是德国,有时只有柏林。(另外,我想按我在geopandas文件中定义为多边形的区域聚合我拥有的数据,但我会在另一个问题中添加这个。)

我如何获得与以下不同的“底图”

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))

用于可视化吗?

示例

# 3rd party modules
import pandas as pd
import geopandas as gpd
import shapely
# needs 'descartes'

import matplotlib.pyplot as plt

df = pd.DataFrame({'city': ['Berlin', 'Paris', 'Munich'],
                   'latitude': [52.518611111111, 48.856666666667, 48.137222222222],
                   'longitude': [13.408333333333, 2.3516666666667, 11.575555555556]})
gdf = gpd.GeoDataFrame(df.drop(['latitude', 'longitude'], axis=1),
                       crs={'init': 'epsg:4326'},
                       geometry=[shapely.geometry.Point(xy)
                                 for xy in zip(df.longitude, df.latitude)])
print(gdf)

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
base = world.plot(color='white', edgecolor='black')
gdf.plot(ax=base, marker='o', color='red', markersize=5)

plt.show()

我该如何将“naturalearth_lowres”地图缩放到南非? - Superdooperhero
1个回答

29

根据 geopandas.datasets.get_path(...) 文档所述,需要执行以下操作:

>>> geopandas.datasets.available
['naturalearth_lowres', 'naturalearth_cities', 'nybb']

数据来源:

  • naturalearth_lowres:国家边界轮廓
  • naturalearth_cities:城市位置
  • nybb:可能是纽约?

其他数据来源

在搜索 "germany shapefile" 后,得到了arcgis.com的网址作为数据源,并使用 "Bundesamt für Kartographie und Geodäsie" 作为数据来源。使用 vg2500_geo84/vg2500_krs.shp 的结果如下:

enter image description here

© Bundesamt für Kartographie und Geodäsie, Frankfurt am Main, 2011 可带有来源进行部分复制、传播和公开使用。

此外,还需要设置 base.set_aspect(1.4),否则地图看起来会很奇怪。值 1.4 是通过尝试获得的。

另一个关于柏林的来源是daten.berlin.de

当geopandas读取这个shapefile时,它是一个包含以下列的geopandas数据帧:

['USE', 'RS', 'RS_ALT', 'GEN', 'SHAPE_LENG', 'SHAPE_AREA', 'geometry']

使用:

  • USE=4 适用于所有元素
  • RS 是类似于16077或01003的字符串
  • RS_ALT 是类似于160770000000或010030000000的字符串
  • GEN 是类似于'Saale-Holzland-Kreis''Erlangen'的字符串
  • SHAPE_LENG 是类似于202986.1998816248309.91235015等浮点数
  • SHAPE_AREA 是类似于1.91013141e+081.47727769e+09等浮点数
  • geometry 是一个shapely几何对象 - 大多数是POLYGON(多边形)

1
也许这篇文章可以帮助你:https://towardsdatascience.com/lets-make-a-map-using-geopandas-pandas-and-matplotlib-to-make-a-chloropleth-map-dddc31c1983d - Martin Thoma
nybb 是指“纽约市行政区边界”:https://data.cityofnewyork.us/City-Government/Borough-Boundaries/tqmj-j8zm - Nicolas

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接