This question already has an answer here:

I know how to generate contour lines from a DEM file once the file is loaded in QGIS and I also know how to open the attribute table for the contour lines which show elevation against IDs. Is there a way to look at elevation values against sets of longitude and latitude values in QGIS? In other words, is there a way to extract and look at XYZ data from a DEM file in QGIS?

marked as duplicate by ahmadhanb, Community Apr 27 '17 at 7:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You could export the DEM as text XYZ but it wouldn't load in most text viewers.. what are you trying to do with the Z for an X,Y? Are you trying to script this? How are you going to determine the X,Y to sample with, a point from a feature class, a mouse click..? You could have a look at gis.stackexchange.com/questions/120555/… and see if that suits your needs. – Michael Stimson Apr 27 '17 at 5:19
  • I was planning to use a mouse click to get the elevation value – Salman Ahmed Apr 27 '17 at 5:54
  • 2
    Using a mouseclick for elevation can be done with the 'identify' tool, which gives you the pixel values for locations you click. – Kersten Apr 27 '17 at 6:59

Two possible solutions come to mind: In QGIS there's the plugin "Point Sampling Tool", and in GRASS the module: v.what.rast. Both of these extract values from a raster for each feature in a point layer.


If I understand correctly, you want to export elevation attributes from a DEM to a point layer?

To do that, you can use the Point Sampling Tool plugin to do just that. Make sure both layers have the same CRS, and run the tool.

enter image description here

The result is a new point layer with an elevation attribute field

  • For now, I only have the DEM file (raster). How do I get a points layer? Do I just make a new vector layer and add random points to it? – Salman Ahmed Apr 28 '17 at 6:30

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