concept xml in category geoprocessing

This is an excerpt from Manning's book Geoprocessing with Python.
GDAL allows you to use XML files to specify the parameters for a map service, and all of the possibilities are documented at http://www.gdal.org/frmt_wms.html. The following listing shows the XML describing an imagery basemap from the US National Map.
Listing 9.6. XML describing a web map service
<GDAL_WMS> <Service name="WMS"> <Version>1.3.0</Version> <ServerURL>http://raster.nationalmap.gov/arcgis/services/ Orthoimagery/USGS_EROS_Ortho_1Foot/ImageServer/WMSServer? </ServerURL> <CRS>CRS:84</CRS> <ImageFormat>image/png</ImageFormat> <Layers>0</Layers> </Service> <DataWindow> <UpperLeftX>-74.054444</UpperLeftX> <UpperLeftY>40.699167</UpperLeftY> <LowerRightX>-74.034444</LowerRightX> <LowerRightY>40.679167</LowerRightY> <SizeX>300</SizeX> <SizeY>300</SizeY> </DataWindow> <BandsCount>4</BandsCount> </GDAL_WMS>
If you use certain styles or layers often, you can store the relevant information in XML files that can be loaded from your script. You can also store entire maps this way, meaning that you can create a map using XML and then render it with Mapnik. If you’d like to see what one of these files looks like, add this line of code to the end of your script:
mapnik.save_map(m, 'nola_map.xml')To render the map described in this XML file to an image, write a script that imports Mapnik and then loads the XML and saves the output like this:
As you can see, the XML is straightforward, so you might even want to define your layers this way from the beginning instead of writing code. Either way, once you have this file, you can delete all of the code from listing 13.9 that creates the atlas layer and style (that’s more than 20 lines) and then replace this