1

I have generated a CSV file (using the MMQGIS plugin) expecting to obtain all the coordinates of a vector layer that I have created. But the output file only contains the latitude and longitude coordinates (and a third column for the shapeid's). Is there a way to obtain also the altitude values?

Edit:

The first picture is from a KML that allows me to add the altitude column in the attributes list, and the second one is from a KML that just adds a column of zeros:

enter image description here

enter image description here

  • Normally Z-coords are not included in a shapefile as a geometry. Can you describe what features (attributes) your table include? What is the data source of the shapefile you use? – dof1985 Jul 20 '16 at 7:35
  • Hi, the MMQGS plugins generates two output files: temp-attributes.csv and temp-nodes.csv. The first file doesn't contain any information (is just a table of one row) and the second one has three columns: [shapeid , latitude , longitude]. The source I used to create a vector layer by hand was Open Street Map... is this what you were asking? – mpm247 Jul 20 '16 at 8:16
  • Looks like this one: gis.stackexchange.com/questions/108833/… – nielsgerrits Jul 20 '16 at 8:18
  • @mpm247 I am not sure that OSM has a Z-coordiante. It might be that any altitude / height attribute if any would be documented in a double precision / float field. Any how, note that mmQGIS has two export to csv tools. If you wish to get attributes you should use the attributes export... tool – dof1985 Jul 20 '16 at 8:33
  • Okay, I will try to get the altitudes as attributes. Thanks! – mpm247 Jul 20 '16 at 10:06
3

From QGIS 2.14 and on:

Create attribute and fill with field calculator with expression:

z ($geometry)


Screenshot from my data.

Version QGIS: 2.16.0 EPSG:28992

enter image description here

enter image description here

  • Perfect! I was looking for something like this. I will try if it works for me. – mpm247 Jul 20 '16 at 10:07
  • One last question, do you know why sometimes the command z($geometry) just provides a new attribute column full of zeros? I have tried it with KML's that I have stored in my computer and it worked, but if I right-click a vector layer created by hand in QGIS and I do a "Save As KML", when I open the field calculator of the new KML file the command that you suggested doesn't work (all zeros). Do you know why? – mpm247 Jul 22 '16 at 10:51
  • As far as I know QGIS doesn't support inserting / updating z-values. I think the points you created in QGIS are 2D and have z-values that are zero. (Adding a point in PostGIS to a 3DPoints table with QGIS 2.16.0 gave me this result.) This is easy to check with the Identify Features as the first printscreen shows. – nielsgerrits Jul 22 '16 at 11:00
  • Oh I see... I though that QGIS always works in three-dimensions, or that at least it was able to provide the altitude of a given pair of latitude-longitude coordinates. I am not able to post images here, so I will put two captures of my "identify features" window in a comment below (or above?) so that you can check if you see something wrong. – mpm247 Jul 22 '16 at 11:25
  • @mpm247 could you please set this answer as the correct one? That wil mark this question answered and removes it from the to do lists. – nielsgerrits Aug 25 '16 at 7:22

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.