I'm trying to create a DEM to go with a simple shapefile (one polygon, four points) in python.

I used fiona to create the shapefile and now need to create the DEM as a tiff file to denote the elevation of the points in the shapefile. I'm stumped. Everything I google looks sooo complicated. How hard can this be?

Some things I don't understand yet include:

  • what is the relation of the dimensions (in pixels) of the tiff file to the shapefile extents? does it matter?
  • what kind of meta data is also stored in the tiff file? e.g. is the CRS stored in the tiff file?

I will be using the output with ArcScene Desktop 10.4.1, but would really like to create everything programatically. I guess if the solution involves arcpy or arcgisscripting, that is not a big problem, but geopandas and fiona sound like the way to go, right?

  • It's not at all clear what you are creating your DEM from, typically you would use contours. Amend your question and show us what the data looks like. Are you trying to assign Z values to your points? You say you only have 4 points, why not just do that manually?
    – Hornbydd
    Commented Apr 5, 2017 at 14:29
  • @Hornbydd I'm trying to set up the BESTest test suite for building energy models for a tool (City Energy Analyst) that uses shapefiles and tiff DEM as input. So, just four points (one rectangular building), and the DEM is uniform to a specific altitude (1609m). I'm trying to do this programatically because I want to automate this testing to be run on every change to the software as a part of our QA. Commented Apr 6, 2017 at 8:36

1 Answer 1


gdal_rasterize is probably the best free utility to burn shapefile attributes into a raster (docs here). In your case these attributes are elevation. It is a command line application though.

From within Python, you can use gdal.RasterizeLayer as seen in this question.

Since you are already using fiona, and you might want to continue using GDAL/OGR wrapper modules, you should look at rasterio (project here) which is by the same author as fiona. rasterio offers a method called rasterize which is a vector-burn function (a little about that idea here and the official documentation on the function).

As for the two other questions:

There is no inherent relationship between vector (shapefile) extent and raster resolution. You decide that relationship. Want a 1-meter DEM? Make the pixel size 1 m.

GeoTIFFs are a subclass of TIFFs. They have specialized metadata to handle CRS. The practical description of GeoTIFFs I always point to is the GTIFF format spec on the GDAL website.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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