I'm working in a way to make hydrologic projects using QGIS and an Excel worksheet that I have. To do this, I want to extract some information of the lines, included in a vector layer, which represents a pipe section.
The information that I need to extract are:
- ID Number
- Length
- X, Y start and end coordinates
I've found a way to capture this field using the "$length" and another algorithm for the X and Y coordinates, but for that I need to open the Attributes table, put the expressions in each attribute column and click to update fields.
Is there a way to when I draw a line these fields are filled in automatically? That is, I draw / edit a line (start editing or end node ) and when I open the attribute table the length fields and coordinates X , Y are filled and updated.
Answer
If you only need these fields inside QGIS, you can use virtual fields. These allow using an expression (like $length
) that depends on other values or the geometry.
Open the field calculator, add a new field with the name length, check the "Virtual Field" checkbox and enter $length
as expression (or something else for the other fields).
These will however not be saved to the excel file.
If you want to keep an excel file in sync with an shp file for geometry and include derived fields in the excel file, there is a plugin called ShpSync that is aware of this concept and updates fields automatically when features are changed, added or deleted.
No comments:
Post a Comment