Let's try one more kind of map that CARTO does very well: the animated time series map. This type of map is used when your data has a date and/or time field representing when an event occurred. The data we'll use represent incidents of gun violence in Philadelphia. Each point is a shooting with a field noting when the event took place. Animating these events over time within a map can show temporal and spatial patterns of violence throughout the city.
- Following the techniques you learned in previous lessons, upload shootings.geojson to CARTO and look at the table.
- Note the different fields that contain a date and/or time. Which one do you think represents the date the shooting occurred? If you said date, you're right. What we don't want to animate is the date that the point was added or updated within the GIS itself (unless we have no better temporal information), therefore we'll ignore the created_at and updated_at fields.
- Click Create Map.
- Click the shootings layer name and click Style to display its style properties.
- Change the aggregation type to Animated. You'll immediately see incidents popping up on the map in animated fashion, but they are all clustered together and it should be apparent that this doesn't make much sense. Can you spot the problem?
The issues is that the incidents are being animated based on their unique ID field in the database, not the date field. Let's go ahead and set that.
- Change the COLUMN to date and observe how the animation changes. Now we are seeing the shootings as they happened over time.You can continue to apply other thematic styling to the layer beyond the animation. Let's change the officer-involved shootings to a red color and leave all the other ones blue.
- Click the fill color, click BY VALUE, and choose officer_involved. Set a value of Y to red and N to blue.Now you should be seeing the occasional red dot appear among the animated incidents.
The animation may be playing a bit fast for your taste at this point. There are lots of settings you can adjust to determine how fast the dots appear and how long they stay on the screen.
- Experiment with the Duration, Steps, Trails, and Resolution properties to get an animation that you feel best helps the viewer get a feel for trends in gun violence over time.
Duration represents how long the animation lasts and Steps are how many frames are involved in the animation. Avoid setting very low values for these.
Trails is how long the incident persists on the map. Somewhat annoyingly, this affects how large the points get before they fade out.
Resolution seems to affect the degree to which overlapping points are displaced so that they can all be seen.
- Share this map and test it in a web browser as you did the previous one. You'll submit this as part of your lesson deliverables.