I try to make a set of maps using QGIS Atlas. My maps will consist of selected feature with it's attributes (using $id = @atlas_featureid, and that's working). Basically - districts in particular city with population, from the lowest to highest. But I want also to show the previous shown features grayed out/in different color/etc. Like here GeoGIF.

I've found that the solution could be a formula $id <= @atlas_featureid. But it's not working properly in my case. The problem I've found is that ID of features in my project does not correspond to the order of features I want to show.

enter image description here

In my project - the order of maps generated with atlas is based on population value, from lowest to highest. How to handle this problem?


I don't think $id has anything to do with the sort order of your districts. if you are sure of your features sort order first build a query in which you add an 'order' attribute (being the 'ranking' of your elements) that you will then use in the styling of your layer.

| improve this answer | |
  • Well, I've done it first. And I think that $id really does a difference here. On the picture above -the marked polygon has $id = 4. All the greyed out features has $id = 0, 1, 2, 3... I've checked it. I this case, since this feature is the first one (with order value = 1) it shall be the only feature selected... – icelandico Jan 20 '18 at 9:59
  • 1
    weird ... i made several tests with different sort orders in the atlas generation. $id are 'static' (i mean : linked to a given feature) and never changed despite the change in the sort oder of the atlas ... – snaileater Jan 20 '18 at 10:15
  • Does the type of column on which the sorting is based makes a difference? I try to do many combinations but still, no progress! – icelandico Jan 20 '18 at 10:21
  • weird you came to a case where $id were 0,1, 2, 3 ... – snaileater Jan 20 '18 at 10:34
  • But in QGIS feature $id starts with 0. $rownum starts with 1. – icelandico Jan 20 '18 at 10:35

I've found the answer. And the $id really makes a difference here. If You want to change the order of features basing on id, there is a MMQGIS plugin. Use "Modify" and "Sort" option to change the $id based on column chosen. Now it's working properly.

| improve this answer | |
  • would be nice to find a solution without that extra step of modifying and saving a copy of the original layer ... – snaileater Jan 20 '18 at 14:30
  • Well, it's problematic since the $id attribute is crucial for shapefile consistency. This solution doesn't take much time and often You only need 1-2 copies of original layer. – icelandico Jan 20 '18 at 18:53

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.