VectorLayer creation, query, display and modify symbology¶

Create a VectorLayer, query the information on the layer, display it on the map and customize the symbology

A set of predefined vector maps are available that can be used by creating a VectorLayer object and passing the name of the map, in this case "nuts1" (Nomenclature of Territorial Units for Statistics). The VectorLayer object can be queried to extract information on layers (datasets present inside the map), the styles (definition of how a layer has to be displayed) and the rules (filter of dataset features to be displayed with specific symbology).

Method printXML() displays the full xml description of a map

In [ ]:
v = inter.VectorLayer("nuts1").opacity(128) 
print v.layers()
print v.styles('nuts1')
print v.rules('default')
print v.get('default','all','poly','fill')
#v.printXML()

Knowing the name of a layer, it's possible to get the list of attributes of the dataset and the distinct values contained on an attribute

In [ ]:
print v.attributes('nuts1')
print v.distinct('nuts1','ICC')

Create a map and display a VectorLayer on it (managing overall transparency)

In [ ]:
map = Map()
map
In [ ]:
v = inter.VectorLayer("nuts1").opacity(255)
map.clear()
tlayervector = map.addLayer(v.toLayer())

Modify symbology of the VectorLayer

In [ ]:
#v.remove('default','all')
#v.remove('default',"[ICC] = 'IT'")
#v.set('poly','fill','#55ff00ff')
#v.set('default','all','line','stroke-width','0.5')
#v.set('default','all','line','stroke','#000077')
#v.set('default',"[ICC] = 'IT'",'poly','fill','#00888877')
#v.set('default',"[ICC] = 'IT'",'line','stroke','#ffff00')
#v.set('default',"[ICC] = 'IT'",'line','stroke-width','2')
#v.set('default',"[ICC] = 'FR'",'poly','fill','#99000055')
#v.set('default',"[ICC] = 'FR'",'line','stroke-width','1.5')
#v.set('default',"[ICC] = 'FR'",'line','stroke','#ff00ff')
map.clear()
tlayervector = map.addLayer(v.toLayer())

Display the VectorLayer on top of a raster ImageCollection

In [ ]:
map.clear()
p = inter.ImageCollection("C03").process()
tlayerraster = map.addLayer(p.toLayer())
tlayervector = map.addLayer(v.toLayer())

Display global airports and railroads

In [ ]:
vr = inter.VectorLayer("railroads").opacity(255)
va = inter.VectorLayer("airports").opacity(255)
map.clear()  
tlayer1 = map.addLayer(vr.toLayer())
tlayer2 = map.addLayer(va.toLayer())
In [ ]: