-
Book Overview & Buying
-
Table Of Contents
Python Geospatial Development - Second Edition - Second Edition
By :
In this section, we will look at some examples of tasks you might want to perform which involve reading and writing geospatial data in both vector and raster format.
In this slightly contrived example, we will make use of a shapefile to calculate the minimum and maximum latitude/longitude values for each country in the world. This "bounding box" can be used, among other things, to generate a map of a particular country. For example, the bounding box for Turkey would look like this:

Start by downloading the World Borders Dataset from:
http://thematicmapping.org/downloads/world_borders.php
Decompress the .zip archive and place the various files that make up the shapefile (the .dbf, .prj, .shp, and .shx files) together in a suitable directory.
Next, we need to create a Python program which can read the borders for each country. Fortunately, using OGR to read through the contents of a shapefile is trivial...
Change the font size
Change margin width
Change background colour