2

I am trying to dynamically update the elevation value of a point based on its location when the user tries to move it in edit mode and after saving it in QGIS. I got a point shapefile and DTM (.asc) raster file. I want to create a custom function which could be added to the expression of the virtual attribute of the point shapefile.

closed as off-topic by ahmadhanb, LaughU, Erik, Jochen Schwarze, whyzar Feb 11 at 14:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – ahmadhanb, LaughU, Erik, Jochen Schwarze, whyzar
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Welcome to GIS SE! We're a little different from other sites. We're a Q&A site, not a discussion forum. You had a tag for PyQGIS that I have removed. For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely. Please check out our short tour for more about how the site works. Thanks. – PolyGeo Feb 11 at 2:03
1

QGIS 3.4

There is a readily available function raster_value() in the QGIS 3.4.

  1. Start the Field Calculator on the attribute table of your point shapefile.
  2. Make sure you will create a Virtual Field.
  3. Expression is raster_value('DTM', 1, $geometry)
  4. Start digitizing new points. The attribute field will be filled by the raster value on-the-fly.

enter image description here

(Sorry it is not clear... I am just hitting Enter key after each click on the map...)

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