I have tried both GRASS v.drape and ThToolBox 2D->3D to attach raster z values to line vertices. I can't tell whether this worked or not since I don't seem to be able to extract the values using python. Perhaps I'm not doing it correctly in python.
layers = QgsProject.instance().mapLayersByName('Lines with Z') layer = layers for f in layer.selectedFeatures(): geom = f.geometry().asPolyline() first_vertex = QgsPoint(geom) print(first_vertex.x()) print(first_vertex.z())
Either z values are not being assigned or I'm not retrieving them correctly. What I am trying to do, which I have not found a tool for, is generate a 2D profile of lines with z on the x-axis and distance on the y-axis with each line starting at 0 and also extract min and max z values for each line along the way.