边界和海岸线干扰 Python Cartopy

Borders and coastlines interfering in Python Cartopy

我正在尝试使用 Cartopy 绘制法国地图,但我对它不是很满意。

在 Internet 上到处搜索 Python 代码,我构建了以下程序:

import cartopy
import cartopy.feature as cfeature
import cartopy.crs as ccrs

import numpy as np

extent = [-4.25, 7.5, 42.25, 51]
central_lon = np.mean(extent[:2])
central_lat = np.mean(extent[2:])

plt.figure(figsize=(8, 8))

ax = plt.axes(projection=ccrs.AlbersEqualArea(central_lon, central_lat))

ax.set_extent(extent)
ax.gridlines()

rivers_50m = cfeature.NaturalEarthFeature('physical', 'rivers_lake_centerlines', '50m')

ax.add_feature(cartopy.feature.BORDERS, linestyle='-', alpha=1)
ax.add_feature(cartopy.feature.OCEAN,facecolor=("lightblue"))
ax.add_feature(cartopy.feature.LAND, edgecolor='black')
ax.add_feature(cartopy.feature.LAKES, edgecolor='black')
ax.add_feature(rivers_50m, facecolor='None', edgecolor='blue', linestyle=':')
ax.coastlines(resolution='10m', color='red', linestyle='-', alpha=1)

plt.show()

这导致以下地图:

这几乎是我想要的,但是......我不明白为什么原始边界(深色虚线)会干扰沿海滨的海岸线(波浪红线),这真的很难看。

有什么办法可以解决这个问题? (知道我想保持陆地边界原样)。

这是可运行的代码。现在绘制的所有要素都具有相同的 scale 或分辨率。可用比例为:110m、50m、10m。

import matplotlib.pyplot as plt
import cartopy
import cartopy.feature as cfeature
import cartopy.crs as ccrs
import numpy as np

extent = [-4.25, 7.5, 42.25, 51]
central_lon = np.mean(extent[:2])
central_lat = np.mean(extent[2:])

plt.figure(figsize=(8, 8))

ax = plt.axes(projection=ccrs.AlbersEqualArea(central_lon, central_lat))
ax.set_extent(extent)
ax.gridlines()

resol = '50m'  # use data at this scale
bodr = cartopy.feature.NaturalEarthFeature(category='cultural', 
    name='admin_0_boundary_lines_land', scale=resol, facecolor='none', alpha=0.7)
land = cartopy.feature.NaturalEarthFeature('physical', 'land', \
    scale=resol, edgecolor='k', facecolor=cfeature.COLORS['land'])
ocean = cartopy.feature.NaturalEarthFeature('physical', 'ocean', \
    scale=resol, edgecolor='none', facecolor=cfeature.COLORS['water'])
lakes = cartopy.feature.NaturalEarthFeature('physical', 'lakes', \
    scale=resol, edgecolor='b', facecolor=cfeature.COLORS['water'])
rivers = cartopy.feature.NaturalEarthFeature('physical', 'rivers_lake_centerlines', \
    scale=resol, edgecolor='b', facecolor='none')

ax.add_feature(land, facecolor='beige')
ax.add_feature(ocean, linewidth=0.2 )
ax.add_feature(lakes)
ax.add_feature(rivers, linewidth=0.5)
ax.add_feature(bodr, linestyle='--', edgecolor='k', alpha=1)

plt.show()

剧情: