1

I have a large number of planned borehole sites. I want to label them in the Attribute Table in order of priority. I would like to select them in that order (priority) and have the Attribute table list them in the order of selection so that I can quickly enter text order.

I can't seem to do this as Show Selected Features doesn't list them in the order selected?

I am using QGIS 3.4.

  • Welcome to GIS StackExchange - If I am understanding...you can click on the column heading to order by that column. If I haven't understood perhaps you can add a screenshot image to your question so we can see what you are working with? – Martin Hügi Jan 30 at 23:24
  • If I'm understanding (differently from @Martin Hügi) - features are not currently numbered, and you'd like to easily give then sequential numbers, based on the order you click them in? – Rostranimin Jan 31 at 0:01
  • As far as I know, QGIS doesn't keep track of the order in which you select features. So the workflow you want to use isn't an option. Another workflow might be possible, like automatically assigning numbers based on spatial location. It would depend on your criteria for assigning priority. – csk Jan 31 at 17:32
1

You need a field in attribute table to assign the priority value. then the field can be used to sort the table.

1

A common method to enter attributes one-by-one when using your field knowledge is:

  1. Open the map and attribute table side by side (or with a bit of overlap, but not too much) .

  2. In the attribute table, select "show selected features" at the left bottom corner of the window.

  3. Make the layer/table editable.

  4. Select the first feature you want to label in the map. You will see it in the table, so it's easy to edit it.

  5. Then you select the next feature, edit, next feature, edit... save and finish.

If your label is in sequential order, you will be able to order by that field to see the features in order of priority. E.g.

PBH0001 (for planned borehole 0001)

PBH0002

PBH0003 ...etc

If you name them -BH1, BH2...BH9, BH10, BH11- you will have problems at the moment of sorting. It's preferable to have plenty of zeros - many projects outgrow the amount of zeroes just because the person doing the design never thought they would be needed.

Note: QGIS, like most other QGIS applications, does not store the records in your preferred order. This might be annoying if you are used to MS Excel, but you will get used to it.

1

As far as I know, QGIS doesn't keep track of the order in which you select features. So the workflow you want to use isn't an option. Here's a slightly different method.

  1. Turn on snapping to vertices for all layers.

    enter image description here

  2. Create a new temporary scratch layer, with geometry type: line. Add a line that connects the boreholes in order of priority.

enter image description here

  1. Extract the vertices of the connecting line, using the Extract vertices tool from the Processing toolbox.

    enter image description here

    This creates a new layer, called Vertices, with one point on each borehole. This layer has an attribute called "vertex_index" where the first borehole you clicked on is 0, the next is 1, etc.

    enter image description here

  2. Install the RefFunctions plugin. Use the Field Calculator to add the vertex_index value to the borehole layer.

    enter image description here

     geomnearest( 'Vertices', 'vertex_index')
    

enter image description here

The field calculator accepts basic arithmetic, so if you want the orders to start with one instead of zero, just add +1 to the expression above.

geomnearest('Vertices', 'vertex_index') + 1

If you don't want to install the RefFunctions plugin, use this method instead of step 4.

Use the Join Attributes by Location tool (Vector menu > Data management) to join the Vertices layer to the Boreholes layer. This creates a new borehole layer. Choose "vertex_index" as the field to add.

enter image description here

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.