Opened 11 years ago

Last modified 10 years ago

#1597 new enhancement

Default sorting of data

Reported by: mwtoews Owned by: nobody
Priority: minor: annoyance Milestone: Version 1.7.0
Component: Data Provider Version: Trunk
Keywords: Cc:
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: no


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.

Change History (4)

comment:1 Changed 11 years ago by gsherman

Why is it important what order the features are drawn?

comment:2 in reply to:  1 Changed 11 years ago by mwtoews

Replying to 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).

comment:3 Changed 11 years ago by pcav

Milestone: Version 1.0.3

comment:4 Changed 10 years ago by pcav

Milestone: Version 1.0.3Version 1.6.0
Note: See TracTickets for help on using tickets.