The most widely used map data should be the shape format, with a lot of free download resources on the network. The function that reads the shape file in Meteoinfolab is Shaperead, the parameter is the file name, and the Layer object that contains the graph and attribute information is returned by the data. Vector layers can be added to the map coordinate system (AXESM) by means of the geoshow function, usually in points, lines, and polygons by primitive type. You can specify the symbol (color, etc.) of the layer's display in the Geoshow function, you can set Facecolor, Edgecolor, size, and so on, all the elements of this layer will be displayed in the same symbol. You can also use the property information of a layer to generate more complex legends (the Makesymbolspec function), the first parameter of the function is an entity type (point, line, polygon), and you need to set an attribute field (field= ' NAME '), Then use the attribute data to set the legend. In this example, the RIVERS.SHP layer is loaded, which is the world's major river, which shows only the Yangtze River and the Yellow River, with the following code:
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)
The example also loads the Chinese provincial capital city Point layer, which can be set in the Geoshow function with parameters such as LabelField to add labels to the layer (city name).
The script code is as follows:
#Set Data FoldersBasedir ='D:/myprogram/distribution/java/meteoinfo/meteoinfo'Mapdir= Os.path.join (Basedir,'Map')#Read shape FilesBou2_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'))#Plotaxesm () 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'italics', Fontsize=16, yoffset=15) Xlim (72, 136) Ylim (16, 55)
Operation Result:
Meteoinfolab Script Example: loading a map layer