I want to "map" or "drape" a 2D vector (polygon) over a raster. Obtaining a 3D vector with z-values according to the raster it's draped over.

Most of my internet findings point towards v.drape. However, this tool seems to only work for polylines, not polygons. Furthermore I am looking for functionality similar to that of ArcGIS 3D-Analyst ("interpolate shape"), where points are inserted in every new raster cell with an according height. Is there a similar tool or combination of tools to achieve this?

Unfortunately, converting the polygon to polylines, draping it and converting it back to polygon does not seem to work either, as the Z-values get lost.

QGIS 2.18.16

  • Make sure you try all of the tools that convert lines to polygons, as they may work slightly differently. I see three tools: QGIS Vector Geometry > Lines to Polygons, QGIS Vector Geometry > Polygonize, and SAGA Vector Polygon Tools > Convert lines to polygons.
    – csk
    Mar 29, 2018 at 17:19
  • I will try if any of those actually maintain the Z values.
    – styx
    Mar 29, 2018 at 18:29

1 Answer 1


You cannot create a new dataset containing a "draped" polygon. Fundamentally speaking, a polygon MUST have all of its point in an arbitrary 2D plane.

As per the OGC's "Simple Features Specification":

2.1.10 Polygon A Polygon is a planar Surface, defined by 1 exterior boundary and 0 or more interior boundaries. Each interior boundary defines a hole in the Polygon.

"Planar" means that it is completely level or flat.

The closest thing you can come to a "draped" polygon stored as a dataset is a TIN, for which there is a guide using QGIS found here, or to maintain the data in raster format. You can use the results of either to query at x,y coordinates to return a z coordinate on the fly.

There are ways to visualize a draped polygon in 3D, but this is done by rendering and recoloring a raster or TIN using the polygon.

  • This is interesting, I didn't know about the definition by the OGC. The issue does not seem to be with storage though, but with creation in QGIS, as Shapefiles can be of type PolygonZ, which is what I am looking for. You are right though, that the term "polygon" strictly speaking probably is wrong.
    – styx
    Mar 29, 2018 at 18:28
  • A PolygonZ is a polygon with 3D coordinates. All the coordinates must however still lie within a single 2D plane, which means you have to be able to rotate the polygon to fit back down to the ground in 2D space. If you want to just raise the 2D polygon off the ground to the value of the raster, then you will have to extract the height of the raster, either at the polygon's centroid, or by averaging the values of the raster under the polygon and using that as all of the vertices' Z coordinate.
    – wfgeo
    Mar 29, 2018 at 19:01
  • Exactely, I do want to create a PolygonZ with individual values for Z at each point. From a container point of view (Shapefile) the point you make about being in a plane or not is not relevant. I can define a triangle (as PolygonZ) and the 3 points will always be within a plane, regardless of their Z-coordinates. It seems however that QGIS tools won't let me do that.
    – styx
    Mar 29, 2018 at 21:41
  • A polygon must have all of its points within a plane. It is not a question of data format, it is a fundamental property of polygons. However, a polygon with 3 points has no restriction on where those three points are located in 3D space, because you can always draw a triangle between them. Adding a 4th point or more will require satisfying this planar condition, given the preceding 3 points. If all of your polygons only have three points, you can use v.drape on a closed polyline and then convert it to a polygon. But keep in mind this will not accurately represent crests or valleys inside.
    – wfgeo
    Mar 30, 2018 at 12:26

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.