Wednesday, 4 January 2017

qgis - Sort selected points by latitude/northing with field calculator


I have bathimetry data in .shp format. The points (picture below shows one of multiple groups/profiles) do not have ID numbers and are randomly dispersed through the attribute table.


enter image description here enter image description here


I have selected each group and added group ID to it. Now each point has "Sort" attribute that serves as the group ID. I still need each individual point to have ID number within the group.


I need these points numbered starting with the northernmost point in group (Field2 in attribute table is northing) and ending with the southernmost. So, a point with highest "Field2" value gets value of 1 in "point_num" field.


Basically, what I need to do is sort selected points according to value of "Field2" attribute. How can I do this with (preferably) QGIS field calculator or some other tool?



Answer



In QGIS 3.0, there is a tool Order by expression which enables you to sort a field Ascending or Descending:



enter image description here


The Ascending is selected by default. If you want Descending just deselect Ascending and it should work.


The tool can be accessed from Processing Toolbox -> Vector General -> Order by expression


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