使用底图绘制经线和纬线
Drawing meridians and parallels using basemap
我有点卡在这上面。我想使用以下代码在地图上绘制经线和纬线:
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# creates an object called map which can plot various things on different projections
plt.figure(figsize=(7,6))
map = Basemap(projection='cyl',llcrnrlat=50.,urcrnrlat=59.,\
llcrnrlon=-7.5,urcrnrlon=3,resolution='l')
map.drawmapboundary()
map.drawcoastlines()
# draw grid plots
map.drawparallels(np.arange(-7.0,2.0,1.0),labels=[1,0,0,0]) #longigtude
map.drawmeridians(np.arange(51.0,58.0,1.0),labels=[0,0,0,1]) #latitude
# make image bigger:
plt.show()
该图工作正常,但没有网格线。有什么想法吗?
您的经线和纬线不适合感兴趣的区域。您的平行线必须是您的经络(您在代码中打印错误):
# draw grid plots
map.drawmeridians(np.arange(-7.0,2.0,1.0),labels=[1,0,0,0]) #longitudes
map.drawparallels(np.arange(51.0,58.0,1.0),labels=[0,0,0,1]) #latitudes
我有点卡在这上面。我想使用以下代码在地图上绘制经线和纬线:
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# creates an object called map which can plot various things on different projections
plt.figure(figsize=(7,6))
map = Basemap(projection='cyl',llcrnrlat=50.,urcrnrlat=59.,\
llcrnrlon=-7.5,urcrnrlon=3,resolution='l')
map.drawmapboundary()
map.drawcoastlines()
# draw grid plots
map.drawparallels(np.arange(-7.0,2.0,1.0),labels=[1,0,0,0]) #longigtude
map.drawmeridians(np.arange(51.0,58.0,1.0),labels=[0,0,0,1]) #latitude
# make image bigger:
plt.show()
您的经线和纬线不适合感兴趣的区域。您的平行线必须是您的经络(您在代码中打印错误):
# draw grid plots
map.drawmeridians(np.arange(-7.0,2.0,1.0),labels=[1,0,0,0]) #longitudes
map.drawparallels(np.arange(51.0,58.0,1.0),labels=[0,0,0,1]) #latitudes