O'Reilly logo

Building Mapping Applications with QGIS by Erik Westra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining the map renderers

Now that we have the map layers, we'll want to set up appropriate symbols and renderers to draw the vector data onto the map. Let's start by defining a method called setupRenderers(), which creates the renderers for our various map layers. Our first renderer will display the track layer, where we use a QgsRuleBasedRendererV2 object to display the tracks in different ways depending on the type of track, whether or not the track is open, and whether it is bidirectional or can only be used in one direction. Here is the relevant code:

 def setupRenderers(self): root_rule = QgsRuleBasedRendererV2.Rule(None) for track_type in (TRACK_TYPE_ROAD, TRACK_TYPE_WALKING, TRACK_TYPE_BIKE, TRACK_TYPE_HORSE): if track_type == TRACK_TYPE_ROAD: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required