Sunday 19 November 2017

Automatically write attribute when creating features in QGIS


Using QGIS 3.0 I have to draw a lot of features on the map and these features have attributes that change with each entry. However, there is a part of the attribute that is the same for all features. How do I automatically write this part of the attribute in the attribute table when creating a new point?


Example:


S1_00001
S1_00002
...
S1_0000N


The S1_ is always the same and can be in a different column as the serial numbering.



Answer



You can set the field default value.


Open the layer properties, go to the field tab and click on the field Text Edit then set the default. Remember that text should be enclosed in single quotes.


You can also derive the value of a field based on other fields (if they all have a default). Assuming you have a column a and b you can set the default of column c as "a" || "b" (note the double quotes to refer to a field)


Now when you create a new features, the default will be used- and you are free to modify it or to keep it as is.


field properties


Default value


Derive default



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...