Thursday 26 December 2019

polygon - Is there a way of auto_increment for the ID column in QGIS


I'm creating a fictive map and so I need to create lots of points, lines and for sure polygons. Later on I export my data as geojson. But before that I aways have to go and give every element an unique ID.


I don't need a special sorting, like the biggest polygon gets the smallest ID or so. I just need all polygons with an ID at the end, without doing it manually like I have to do now.


Would be great if someone knows how to do that.



Answer



Using the field calculator is the way to go:


No ID was given in



  1. Digitize every features without any entering any Id.

  2. Before export, update unique Ids with the expression, '$Id' using the field calculator.



No ID given


Some ID's already given in



  1. If you have already ID's you can use '-$Id'. Make sure you just select new Features what means that that are 'NULL' in the id row. Simply do that by ordering the column.

  2. Now do the steps from the pictures:


enter image description here enter image description here


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...