Feature request #1597

Default sorting of data

Added by Mike Taves about 15 years ago. Updated about 8 years ago.

Category:Data Provider
Pull Request or Patch supplied:No Resolution:fixed/implemented
Easy fix?:No Copied to github as #:11657


Presently, feature data are not sorted by QGIS. Also, databases do not return data in any particular order, unless explicitly sorted (e.g., "SORT BY field1 ASC, field2 DESC"). From a GIS perspective, this determines which features are drawn from first to last, which is noticeable if they are stacked (particularly polygons).

I have worked around this limitation by building VIEWs in PostgreSQL:

CREATE OR REPLACE VIEW ordered_features AS 
 SELECT gid, geometry, collection_date
   FROM features
   ORDER BY collection_date DESC;

and adding the metadata to geometry_columns.

It would be of great convenience to be able to sort geometry features within QGIS. A potential solution for this is to add a field in Layer Properties > General, beneath Subset (aka "SQL where clause"). This could be a simple text field "SQL order clause" that gets inserted into the SQL statement when requesting data.


#1 Updated by Gary Sherman about 15 years ago

Why is it important what order the features are drawn?

#2 Updated by Mike Taves about 15 years ago

Replying to [comment:1 gsherman]:

Why is it important what order the features are drawn?

This is important for data that happens to pile up in the same or similar place. I can think up two good examples:

Time-variable data, for example polygons of building outlines. I would like to draw the oldest buildings first followed by the newer ones. This way, the current (or at least most recent) buildings are on top. I have layers of buildings that stretch back into the 1940s, many of which have been demolished with new ones built in the same areas.

Symbol levels for points. I often have multiple points at one location that is stylized using the unique value symbology. There are certain symbols (such as "contaminated" red dot) that are more critical to see on the map than others (such as "not contaminated" green dot). (Alternatively, it might make more sense that control of symbol levels should be part of the layer properties for unique value symbology -- especially since it is difficult to sort text classifications unless they happen to be alphabetical).

#3 Updated by Giovanni Manghi over 12 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#4 Updated by Giovanni Manghi about 12 years ago

  • Target version changed from Version 1.7.4 to Version 2.0.0

#5 Updated by Pirmin Kalberer over 11 years ago

  • Target version changed from Version 2.0.0 to Future Release - Nice to have

#6 Updated by Nyall Dawson about 8 years ago

  • Pull Request or Patch supplied set to No
  • Status changed from Open to Closed
  • Assignee deleted (nobody -)
  • Resolution set to fixed/implemented

This was implemented in 2.14

Also available in: Atom PDF