Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can anyone suggest a quick (and preferably open source) way to create an image from a shapefile. For example, I have a shapefile containing parcel boundaries, I want to create a png file depicting these parcels. The symbology required for this image will be bare-bones (solid outline and fill).

I know that shp2img from MapServer would do the trick. I am just curious if there is anything else available.

Any references to pre-compiled tools or api's/sdks welcome.

share|improve this question
Perhaps this question could be retitled "Creating simple image from vector data (eg Shape)" so that it's a more generic question? You still get your answer, but there's more of an incentive for other folk to view/answer too. I'd also suggest changing "and open source" to "preferably open source" for the same reason. – Mark Ireland Nov 1 '10 at 16:22
Good points, edits applied. – user890 Nov 2 '10 at 1:02
up vote 15 down vote accepted

You can use python (modules: shapley, GDAL/OGR, numpy, matplotlib) and GDAL/OGR to draw image from almost any vector data souce, in you case shapefile. Maybe this will help you.


from shapely.geometry import Polygon
from shapely.wkb import loads
from osgeo import ogr
from matplotlib import pyplot

def drawPoligon(poligon,graf):
    xLista,yLista = poligon.exterior.xy
    graf.plot(xLista,yLista, "k-")

fig = pyplot.figure(figsize=(4, 4),dpi=180)
ax = fig.add_subplot(111)
file1 = ogr.Open("d:\\temp02\\datafile.shp")

layer = file1.GetLayerByName("datafile")
parcel = layer.GetNextFeature()

while parcel is not None:
    geometryParcel = loads(parcel.GetGeometryRef().ExportToWkb())
    drawPoligon(geometryParcel , ax)
    parcel = layer.GetNextFeature()

share|improve this answer
Exactly what I needed. This approach is especially useful since it is not tied to shapefile data sources. Thanks. – user890 Nov 2 '10 at 0:58

Quick, cheap (and dirty):

  • open and symbolise your shape file with a qgis, udig, openjump or any other free GIS,
  • press "print screen" button,
  • paste in gimp and save as png file.

Drawback: of course, the image resolution cannot be finer than the screen's one.

share|improve this answer

GeoTools contains all the bits you need to do this, I'd be surprised if someone doesn't already have the code somewhere to do this.

share|improve this answer

I guess that it depends on what you mean by quick. Do you mean something easy to install or something that is easy to use once you have it installed.

You mention MapServer and shp2img. If you have MapServer installed, you could probably write a pretty simple MapScript (Python or php) script that would loop through a folder of shapefiles and render images of them with default symbology.

share|improve this answer

This question is already answered, but I'll put some additional information, as it might be helpful for someone. This mailing list explains how to convet SHP to Images, and currently I am working with it to complete the task:

share|improve this answer

I documented this soltuion a little while back using two different methods.

One using pure Python which will run anywhere Python does:

And one using the Python Imaging Library:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.