yaqiang

MeteoInfoLab脚本示例:添加南海脚图

添加南海脚图实际上就是增加一个地图坐标系(Axesm),在用axesm函数创建地图坐标系的时候可以指定position参数(即位置和大小),第1和第2个参数是坐标系的左下角x, y位置,后两个参数是坐标系的宽度和高度,单位都是Figure的归一化坐标(0 - 1)。由于地图坐标系在Figure缩放时需要保持地图x, y坐标比例不变(地图不发生变形),坐标系具体绘制的位置会随着Figure缩放而变化,需要提前设置好Figure大小,再调整position参数。

脚本程序:

#Set data folders
basedir = \'D:/MyProgram/Distribution/java/MeteoInfo/MeteoInfo\'
mapdir = os.path.join(basedir, \'map\')
#Read shape files
bou2_layer = shaperead(os.path.join(mapdir, \'bou2_4p.shp\'))
bou1_layer = shaperead(os.path.join(mapdir, \'bou1_4l.shp\'))
river_layer = shaperead(os.path.join(mapdir, \'rivers.shp\'))
city_layer = shaperead(os.path.join(mapdir, \'res1_4m.shp\'))
#Plot
axesm()
geoshow(bou2_layer, edgecolor=\'lightgray\')
geoshow(bou1_layer, facecolor=(0,0,255))
ss = makesymbolspec(\'line\', {\'value\':\'Yangtze\', \'color\':(0,255,255), \'size\':1}, \
    {\'value\':\'Huang He\', \'color\':(0,255,255), \'size\':1}, field=\'NAME\')
geoshow(river_layer, symbolspec=ss)
geoshow(city_layer, facecolor=\'r\', size=4, labelfield=\'NAME\', fontname=u\'楷体\', fontsize=16, yoffset=15)
xlim(72, 136)
ylim(16, 55)
#Add south China Sea
sc_layer = shaperead(os.path.join(mapdir, \'bou1_4l.shp\'))
axesm(position=[0.14,0.18,0.15,0.2], axison=False)
geoshow(sc_layer, facecolor=(0,0,255))
xlim(106, 123)
ylim(2, 23)

 

运行结果:

分类:

技术点:

相关文章:

  • 2021-10-14
  • 2021-11-10
  • 2021-12-01
  • 2021-11-22
  • 2021-09-08
  • 2021-11-28
  • 2021-06-17
猜你喜欢
  • 2021-10-08
  • 2021-12-02
  • 2021-10-26
  • 2021-05-18
  • 2021-04-14
  • 2021-08-28
  • 2021-11-27
相关资源
相似解决方案