Wednesday, 8 July 2015

shapefile - Automate SHP to JPG creation


Does anyone know of a way to batch convert shapefiles to jpegs or another common image format?


edit: I should have clarified that I would like to apply a styling to each shapefile, and then export the shapefile with that styling to an image.


For example, I have census tracts in a county, and I want an image of each individual tract highlighted while the other tracts are all the same color.



Answer



There are many free tools like:



But in Python, the reference is Mapnik and Getting Started In Python




  • You create a map (width and height in pixels, background color, etc)

  • You create Styles which determines how the data is rendered

  • You add a datasource (shapefile, etc.) and create a layer from it.

  • You render the map

  • the same map and styles parameters can be applied to multiple files (via an XML file)


see the examples in Mapniks Maps


Simple Rendered images from TM_WORLD_BORDERS-0.3.shp


enter image description here


selection of a country (Angola) in the shapefile:



enter image description here


Another example from Mapniks Maps


enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...