2

Is there a way to make the season appear next to the year in Time Manager instead of the month? In the settings, I currently have DateTime selected with %Y-%m in the box. This makes the displayed time read 2017-10, for example.

I'm trying to make my frames into a GIF when I'm done and I'm hoping to not have to edit each individual frame in GIMP. Alternatively, if there's a way to edit the frames outside of QGIS in another program, I'm open to that, but I realize that a different stack exchange is dedicated to that kind of stuff.

2

You can use an expression like this to convert the month to a season name.

case 
 when month("datefield") in (12,01,02) then 'Winter' 
 when month("datefield") in (03,04,05) then 'Spring' 
 when month("datefield") in (06,07,08) then 'Summer' 
 when month("datefield") in (09,10,11) then 'Autumn'
end

Notes:

  • Adjust months and season names to match your local seasons.
  • Substitute the name of your date field where the expression says "datefield".
  • You can use this expression to create a new field with the Field Calculator, and then label the features with it. But I think there's a better way (see below).

The next step is figuring out how to display the "Season" value of the current feature on the image exported by the Time Manager plugin. Here's one method. QGIS has lots of graphic options, so there are probably other ways that I haven't thought of.

  1. Substitute animation_datetime() for "datefield" into the above expression.

    case 
     when month(animation_datetime()) in (12,01,02) then 'Winter' 
     when month(animation_datetime()) in (03,04,05) then 'Spring' 
     when month(animation_datetime()) in (06,07,08) then 'Summer' 
     when month(animation_datetime()) in (09,10,11) then 'Autumn'
    end
    
  2. Use that expression to put a label on the map at a fixed location. Make sure it doesn't conflict with the Time Manager date stamp. Fix the location using the data-defined label placement settings, as shown in the image below.

    enter image description here

If you want to display the season plus an additional value like the year (eg, Spring 2015), use concat(string1,string2,string3), like this:

concat( [the expression from step 1], ' ', year(animation_datetime()) )
  • This code works perfectly, and I can set up the label to sit at a single point, thank you! Is there a way to include the year in the code so it comes after the season? Rather than having the season come from the label and the year from the TimeManager time display options? – pfadenhw Jul 18 at 19:55
  • Also, TimeManager might not have liked your test data if your month values were only one digit. I believe all the acceptable date formats for TimeManager are two digits (i.e. 01 for Jan). I changed your code to include 0s before the single digit months and that worked for me. – pfadenhw Jul 18 at 19:59
  • Thanks for the feedback, I'm glad it works. I'll update my answer accordingly, and also add a formula for displaying the year in the label. – csk Jul 18 at 20:05

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.