如何为 python cartopy 几何体设置偏移量?

How to set offset for python cartopy geometry?

所以问题是,当我将 .shp 文件中的几何图形添加到 cartopy 图形时,有一个偏移量,我不知道如何设置偏移量。

我是 python 的新手,非常感谢您的帮助。

picture here

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

from cartopy.io.shapereader import Reader


canada_east = -63
canada_west = -123
canada_north = 75
canada_south = 37

standard_parallels = (49, 77)
central_longitude = -(91 + 52 / 60)

data = Reader('icitw_wgs84')

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1,
                     projection=ccrs.LambertConformal(central_longitude=central_longitude,
                                                      standard_parallels=standard_parallels))
ax.set_extent([-79.65, -79.1, 43.57, 43.87])


ax.add_feature(cfeature.LAKES.with_scale('10m'))
ax.add_feature(cfeature.LAND.with_scale('10m'))
ax.add_feature(cfeature.RIVERS.with_scale('10m'))


ax.add_geometries(data.geometries(), crs=ccrs.Geodetic(), edgecolor='k', facecolor='none')

我认为您看到的是低分辨率 land/lake 数据集造成的。对于这种比例的地图,您最好使用地图图块而不是 NaturalEarth 土地要素。 cartopy 中已经有多种选择,Stamen Terrain 或 Open Street Map 可能是不错的选择:

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

from cartopy.io.shapereader import Reader
from cartopy.io.img_tiles import StamenTerrain, OSM

standard_parallels = (49, 77)
central_longitude = -(91 + 52 / 60)

data = Reader('citygcs')

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1,                  
                     projection=ccrs.LambertConformal(central_longitude=central_longitude,                                     
                                                      standard_parallels=standard_parallels))
ax.set_extent([-79.65, -79.1, 43.57, 43.87])

tiler = OSM()
ax.add_image(tiler, 10)

ax.add_geometries(data.geometries(), crs=ccrs.Geodetic(), edgecolor='k', 
facecolor='none')
plt.show()

或使用StamenTerrain:

关于引用椭圆可能还有其他问题(我在 shapefile 名称中注意到 WGS84),这里有一个很好的参考:https://scitools.org.uk/cartopy/docs/v0.16/gallery/effects_of_the_ellipse.html.

如果您的代码示例最少并且所有数据都可用(我不得不自己去寻找一个类似的 shapefile 来重现),将来会有所帮助,请参阅此处获取指南:https://whosebug.com/help/mcve.