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
There is a readily available function raster_value() in the QGIS 3.4.
- Start the Field Calculator on the attribute table of your point shapefile.
- Make sure you will create a Virtual Field.
- Expression is
raster_value('DTM', 1, $geometry)
- Start digitizing new points. The attribute field will be filled by the raster value on-the-fly.
(Sorry it is not clear... I am just hitting Enter key after each click on the map...)