3

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.

  • What software are you using? – Marcelo Villa Apr 9 '18 at 12:26
  • You need to give some information on your working environment ~ software? scripting? etc – nmtoken Apr 9 '18 at 12:26
  • I use QGIS 3.0 and – Goran Apr 9 '18 at 12:30
5

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

  • Which also works with my suggested "code". Neat =) – Erik Apr 9 '18 at 13:21
-1

Assuming you're using QGis: You can't get automatical entries in QGis, at least not that easy. If you're working with a database, you could create a trigger which adds a value, but I neither now how, nor if your desired input would be possible.

What you can do, is the following: Create all your features, then use the field calculator with the following expression

concat('S1_',lpad(to_string($id),5,'0'))

concat puts two strings together, lpad fills up the left side of a string to a given number (here 5) with a desired character (here 0), and $id simply is the ID of your entry.

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.