0
Python3
與cartopy
工作時,我正在嘗試從Natureal Earth數據庫中繪製一個特定的河流。Cartopy:繪製特定河流的子集特徵
這是很簡單的繪製所有河流和然後設置的程度在特定區域:
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature
rivers = cartopy.feature.NaturalEarthFeature(
category='physical', name='rivers_lake_centerlines',
scale='10m', facecolor='none', edgecolor='blue')
fig, ax = plt.subplots(
nrows=1, ncols=1, subplot_kw={'projection': ccrs.PlateCarree()},
figsize=(10,6))
ax.add_feature(rivers, linewidth=1)
ax.set_extent([-65, -45, -40, -17.5])
plt.show()
(如下所示結果)
但是,如果我希望僅繪製特定的河流(爲了說明Paraná,由於編碼問題在數據中被命名爲Paran?
,似乎沒有明確的方式來做到這一點)The cartopy Feature interface documentation
任何想法如何使河流繪製線條,而不是多邊形? – mbarete
愚蠢的問題 - 用'ax.add_geometries([rec.geometry],ccrs.PlateCarree(),edgecolor ='blue',facecolor ='none' – mbarete