我知道我可以将自定义背景地图添加到 geopandas 数据框,如下所示
ax = df_wm.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')
cx.add_basemap(ax, source=cx.providers.Stamen.TonerLite)
ax.set_axis_off()
我怎么能使用其他地图块。例如,USGS 地形图块,就像下面国家地图中的那些图块一样? https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/7/46/26
要从标准来源获取地图背景的网络地图图块,您需要识别
url
和 layer
并在您的代码中使用它们。这是一个使用 cartopy 请求服务的演示脚本。
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
url = "https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/WMTS/1.0.0/WMTSCapabilities.xml"
layer = "USGSTopo"
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
# The requested maps will appear as data that
# matplotlib can plot on its `ax`
ax.add_wmts(url, layer)
ax.set_extent([20, 25, 35, 40], crs=ccrs.PlateCarree())
ax.plot([20.1, 22.7, 24.5], [35.5, 37.2, 39.2])
ax.gridlines()
ax.set_title('USGSTopo WMTS')
plt.show()