Python Basemap没有显示正确的图

时间:2017-07-04 05:47:50

标签: python-3.x matplotlib jupyter-notebook matplotlib-basemap

我需要在阿姆斯特丹市的地图上绘制一些数据,但我无法让Basemap显示正确的情节。使用下面的代码,我得到的只是一个空图,我不知道如何让地图显示。

我的代码如下:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
%matplotlib inline

#Create a map around Amsterdam
#http://www.latlong.net/
#Upper Right Corner 52.4268763,5.2415393
#Lower Left Corner 52.3303609,4.6992733

#fig, ax = plt.subplots()
m = Basemap(projection='merc', 
        llcrnrlat=52.3303609,urcrnrlat=52.4268763,
        llcrnrlon=4.6992733, urcrnrlon=5.2415393,
        resolution='c')

m.fillcontinents()
m.drawcoastlines()
m.drawmapboundary()
plt.show()

我的代码中缺少什么?

1 个答案:

答案 0 :(得分:2)

您为底图选择的分辨率resolution='c'是“粗略的”,这意味着不会显示详细的海岸线。您可以使用任何其他可能的解决方案

l (low), i (intermediate), h (high), f (full)

示例:

resolution="l"
enter image description here

resolution="i"
enter image description here

resolution="h"
enter image description here

resolution="f"
enter image description here

重现的代码:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

m = Basemap(projection='merc', 
        llcrnrlat=52.3303609,urcrnrlat=52.4268763,
        llcrnrlon=4.6992733, urcrnrlon=5.2415393,
        resolution="f")

m.fillcontinents(color='bisque')
m.drawcoastlines()
m.drawmapboundary(fill_color='lightcyan')

plt.show()