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, this time leaving the Auto-guessing slider on. This way, the data types will be preserved, in particular, the Data field we'll need for the time-series widget.
- Look at the table in the Data Preview section of Data Explorer.
- 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.
- Create a new map with the shootings data.
- Use the tools in the CARTO Builder to add a Time Series widget using the shootings data you uploaded.
- Be sure that the field the widget is using is the Date field.
- Be sure that Animation Controls slider is on.
- Click on the widget and look at the panel below the map. You should see a Play button that will animate the map, showing events 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.
- Use the layer style tools to creat a custom color scheme with two colors: red and blue, and specify that it is an Ordinal Scale. Next to the Point 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. You may want to increase the size of the point symbols to see them more easily.
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.
- Use the Share button at the top of the window to Publish your map and generate a Public Share Link. Paste that url link into a new browser window to see how your map may be viewed by other users. Explore the functionality, in particular, the ability to click and draw a range of times in the animaion window to aggregate activity temporally. You'll include the link to your animation map as part of your lesson deliverables.