2

I have been trying to make an animation with the Temporal Controller in QGIS using a custom .csv file, created by merging lat, lon, arrival_time, departure_time, stop_name and stop_id.

It currently looks like this:

enter image description here

These are the Temporal Controller tab settings:

enter image description here

I have tried converting arrival_time and departure_time to datetime instead of, as they currently are, just date; however, this made no difference and it kept not working.

Current behaviour:

Once the .csv layer is added and the Temporal Controller is active, the dots effectively display on the viewer. However, upong activating it, the timeline starts moving but the dots never move.

Expected behaviour:

The dots to move, like in this or this tutorial.

7
  • There is a lot of information missing to give an answer. What settings did you make for Animation range and Step or Frame rate, what time range does your data cover, what settings did you make in the temporal tab in layer properties? Can you 1) add screenshot for this and 2) provide sample data for testing?
    – Babel
    Aug 10, 2022 at 20:54
  • Sure thing, here you have: Animation range is the full extent of the .csv file, from 2022-07-15 to 2022-08-01. Step is 1 minute, and Frame rate is 1 frame per second. With these settings, the dots only appear at the begining but upong clicking Play, they just disappear. I have edited my question and added an image of the data. As the .csv file is quite heavy, I'll have to find some other way to share it here.
    – Trikelians
    Aug 10, 2022 at 21:50
  • arrival- and departure time is always the same: so start and stop is in the same moment. maybe that's why nothings shows up? I still don't see which settings you made in the temporal tab in layer properties.
    – Babel
    Aug 10, 2022 at 21:55
  • Maybe yous copy/paste the CSV formatted as code to your question so we can copy it and create an on CSV file - no need to share the whole file.
    – Babel
    Aug 10, 2022 at 21:56
  • Updated my original question to add the requested data.
    – Trikelians
    Aug 10, 2022 at 22:17

2 Answers 2

2

Below is an animated GIF of what I get following the process described by @Babel. (You may need to click on it to see it animate.) Do you see the same values for Animation range, Step and Current frame?

Animation of red dot appearing and moving across map at 1 second intervals. The QGIS Temporal Controller is visible, with a Step of 1.000 minutes.

There are some frames where the dot is not visible. This is because Layer PropertiesDynamic Temporal ControlEvent duration is set to 1.00 Minutes. Where these is a gap of more than 1 minute between the arrival_time of features in the CSV, there will be no feature visible for one or more frames.

Screen capture of QGIS Dynamic Temporal Control with Configuration set to Single Field with Date/Time, Limits set to Include Start,Exclude End, Field set to arrival_time and Event duration set to 1.00 Minutes.

1

Edit: see here how to create an animation with interpolated points.

The data format you use in your CSV cannot be interpreted when you load to file to QGIS: even if you set the field type to datetime, the attribute values will be NULL.

Also be aware to make the right settings: your arrival- and departure times are identical, so depending on the settings, the point never appears: the moment it should appear (arrival) is the same moment it already disappears (departure). I'm not sure what the intention is behind these data. Better use a separate field for Event duration or make sure you don't have the same values for arrival and departure.

Still, with the data you have, you can create an animation respecting these steps:

  1. So when you import the CSV to QGIS, set the field type for arrival_time and departure_time to string.

  2. Save the imported layer as Geopackage - CSV-based layers can't be edited!

  3. Use field calculator to convert the two fields containing the datetime information in string format to datetime format. Use this expression for the field departure_time and replace departure_time with arrival_time for the field arrival_time:

    to_datetime(
        right (left (departure_time, 10), 4)  || '-' || 
        right (left (departure_time, 5), 2)  || '-'  || 
        left (departure_time, 2)  || ' '  || 
        left (right (departure_time, 5), 2)  || ':'  || 
        right (departure_time, 2)
    )
  1. In layer properties, make the settings for temporal controller, using temporal tab. In my case, the following settings worked:
  • Configuration: Separate Fields for Start and End Date/Time

  • Limits: Include Start, Include End

  • For Start-Field and End-Field, use the fields created in step 4

    enter image description here

  1. Activate Temporal Controller Panel, Click on Fixed range temporal navigation and click the icon with two arrows Set to Full Range to load earliest and latest datetime value:

    enter image description here

  2. Click on the button Animated temporal navigation and click the play button.

5
  • 2
    For step 3, wouldn't it be simpler to use to_datetime with a format string: to_datetime(arrival_time, 'yyyy-MM-dd HH:mm:ss')? Follow these links for documentation on the date and the time parts of the format string. Regardless of how you use to_datetime, be aware that the datetime generated will assume the input string is in your current system time zone. This does not seem to be easy to change to UTC, or anything else.
    – Cowirrie
    Aug 15, 2022 at 5:55
  • 1
    Indeed, this is what I tried first. Weirdly, on the QGIS installation, it did not work. On the QGIS installation here, it works fine - it even recognizes the dattime format, making steps 1 to 3 needless at all.
    – Babel
    Aug 15, 2022 at 14:30
  • Trying the to_datetime method, as @Cowirrie suggested, definitely works. @Babel, thank you very much for the detailed explanation. However, on the last step, I still cannot see any dots moving; they just blink. Would you mind to share a gif of your outcomes, just to compare them?
    – Trikelians
    Aug 15, 2022 at 17:29
  • What do mean by "moving"? The dots will not move, they will appear and disappear on the spot where they are located. So one after the other appears - if you have enought points, this creates the illusion of moving. There is no (not yet?) a possibility to interpolate points in between the ones you have saved. This was possible in the Timemanager Plugin. This might still work. Other option is to add additional points or create lines between points and just show a substring of it, based on the time elapsed. This, however, would be a different question.
    – Babel
    Aug 15, 2022 at 17:41
  • 1
    @Trikelians see here how to create moving points with interpolated animation: gis.stackexchange.com/questions/438399/…
    – Babel
    Aug 16, 2022 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.