Feature request #1597
Default sorting of data
|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.
#2 Updated by Mike Taves over 13 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).