4

So I have a shapefile with 40 polygons(rows) and 30 columns where each column represent values from different time period.

I have created a map with graduated style by choosing values from one column but I want to do the same for every column. And if it's possible in QGIS, I need an animation or at least a slider to see differences through time.

Do I have to do that through web application or QGIS is capable of that (without writing a script). I am aware of time manager and mmqgis plugins but I believe they don't fit to my needs.

1

Late answer, but better than never...

First of all I think you need one graduated style that matches all of your columns, i.e. if an attribute value ranges from 0 to 30 at the beginning and from 20 to 50 some periods later your style should cover values from 0 to 50 to make things comparable (and otherwise my approach does not work).

I have created a small table structured as follows:

enter image description here

As you can see values range from 5 to 35, so I create a style ranging from 0 to 40 in intervalls of 5:

enter image description here

Now in the layer properties where you select the column an expression is needed, that selects a different column e.g. each second:

enter image description here

(klick on the ε right to the column combo box)

enter image description here

Here is the expression in plain text:

case
  when to_int(epoch(now()) / 1000) % 3 = 0 then "1970"
  when to_int(epoch(now()) / 1000) % 3 = 1 then "1990"
  when to_int(epoch(now()) / 1000) % 3 = 2 then "2010"
end

This counts the seconds (integer) since 1970, devides it by 3 and selects a column according to rest of the division. In other words, toggles the column every second. You may simply replace the 1000 for other time intervalls an the 3 according to your column count.

Note that the style does not refresh automatically, this can be achieved by a neat little python script that initializes a timer and calls a funtion that refreshes the layers every 1000 ms (you can directly type this in the editor of the python console):

enter image description here

def refreshAll():
    iface.mapCanvas().refreshAllLayers()

timer = QTimer()
timer.timeout.connect(refreshAll)
timer.start(1000)

If you start this script (press play button in the editor) your animation will immediatly start.

The result can be seen here: https://www.youtube.com/watch?v=mMgiwJlEOxs

  • 1
    Thanks @Jochen Schwarze. I couldn't find a solution at that time and I used the leaflet library to create an animated map. You can see it here link. Thanks again! – geoSAM Oct 18 at 9:33
2

As far as I know there is no tool which does what you want in QGIS. Therefore, I would suggest to restructure the data. In most cases that should be much less work than developing a new tool.

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.