所以问题是,当我将.shp文件中的几何图形添加到Cartopy图形中时,存在一个偏移,并且我不知道如何设置偏移。
我是python的新手,所以能获得任何帮助。
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')
答案 0 :(得分:1)
我认为您看到的是由于分辨率较低的陆地/湖泊数据集。对于这种比例的地图,最好使用地图图块而不是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://stackoverflow.com/help/mcve。