O'Reilly logo

Geospatial Development By Example with Python by Pablo Carreira

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

Styling maps

Now that we have a function to generate the map and an easy way to preview them, we will experiment with the style options:

  1. First, lets produce a bigger map so we can better see the changes. Edit the if __name__ == '__main__': block at the end of the map_functions.py file, changing the size argument of the create_map function call:
    if __name__ == '__main__':
        map_image = '../output/world3.png'
        create_map('../../data/world_borders_simple.shp',
                   'map_style.xml',map_image, size=(1024, 500))
        display_map(map_image)

Map style

The map is the canvas for the drawing; it is possible to change the background color or the background image, the coordinate reference system, and a few other options.

Let's try changing the background:

  1. In the file map_style.xml ...

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