Meteoinfolab Script Example: loading a map layer

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.