2

I have a TIN representing a digital terrain model, and another polygon layer representing features (e.g. building outlines) which is assumed to 'sit' on top of the DTM. How do I calculate the elevation of the TIN at the position of each vertex in the feature layer, and then add this to the feature layer?

Presumably the first step will be to convert the polygon layer from 2D to 3D so there is a way of storing the elevation of each vertex, but then I am at a loss on how to populate the z values.

  • You want to add elevation information to every vertex of the feature? if you just want to add that information then you can just add a column to the attribute table of the polygon layer and store the elevation information there. – Hasan Mustafa Feb 24 '16 at 11:35
  • Hello Hasan, if I add a column to the attribute table, would I not just end up with a single height attribute for each feature? This isn't quite what I need, as the features might well be on a slope (almost certainly) and so each vertex of a feature will be at a different elevation. I can't see how you could capture that in a single attribute field? – Sam Feb 24 '16 at 11:47
  • You are right, that would only work if every vertex was a different attribute, you will have to change the polygon type ( I have seen MultiPolygonZ and MultiPolygonZM in PostGis used for 3d and 4d data ) – Hasan Mustafa Feb 24 '16 at 11:57
  • There's a plugin called point sampling tool. It can extract the values from an underlying raster but as the name suggests, it only works with points. You can extract the nodes of each polygon into a separate point layer and then work from there. I haven't seen any function that can perform exactly what you need, but you can probably find a workaround. +1 to what Hasan said about having the PolygonZ. This is supported in shapefiles but haven't tested it in QGIS. In this case you don't see Z values in the attribute table but only if you enable editing on the layer and see the vertex editor. – Techie_Gus Feb 24 '16 at 15:48
  • Gus, Thanks.... so if I understand correctly you are suggesting generating a raster grid of elevations from the TIN, converting the polygon layer to points, and then using the point sampling tool to read the value of the raster cell at each point. – Sam Feb 26 '16 at 11:50
0

New in QGIS 3.4, there is a Drape (set z-value from raster) tool in the Processing Toolbox, which will set the z-value of each vertex in vector layer from a raster layer (eg DEM).

This is a better option than converting a linestring or polygon to points, though you'll probably need to convert your TIN to a raster DEM.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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