Geodatabase secrets: Creating animations with a One-to-Many join
The geodatabase is full of surprises. In this blog post we will leverage a One-to-Many join between a feature class and a standalone table in a geodatabase to create a time aware animation.
In Desktop Technical Support, we have the opportunity to assist customers who are working on some very interesting projects. As temporal data becomes more prevalent, we often get questions regarding workflows for working with temporal data and animations in ArcGIS for Desktop. Katelyn, one of our support analysts, recently assisted a customer who was trying to create an animation with temporal data that resided in a joined table that had a One-to-Many cardinality. The solution to his problem exposed some useful functionality that is particular to geodatabases and table joins and she wrote the following blog post describing the workflow that was used to achieve the client’s desired animation.
This post will focus on the visualization of temporal data saved in a standalone geodatabase table joined to a polygon feature class with a One-to-Many relationship. The polygon feature class symbolizes geographic features that do not change shape or location over time, but with attributes which change over time. In this post, we will explain how to visualize the population of Canadian provinces from 1971 to 2006 using the Time Slider window in ArcGIS for Desktop while leveraging the temporal data that is in a joined table.
Data management best practices suggest storing data in different tables to avoid data redundancy. Data may also be in different tables when it comes from different sources. This storage method is actually useful in this animation scenario, as the geographic features are stored in one table, and the associated data is stored in the other. In this example we have a polygon feature class of Canadian provinces and a standalone table of yearly provincial population values. Both are stored in a file geodatabase. To animate the change in population of Canadian provinces with this data a table join is used between the two tables. This join can be created using the Join Dialog box or the Add Join tool.
Here’s where the geodatabase becomes very handy. We can use a table join with a One-to-Many relationship to create an animation. I’m sure many of you are thinking, “but wait, table joins only support One-to-One relationships”. That’s true for the most part, no matter what data format you use, your origin table will only display the first occurrence of a match from the joined table. However, with geodatabase data you are able to take advantage of One-to-Many relationships with a table join even though you only see the first joined record in the layer’s attribute table. That’s really interesting because it allows us to animate a set of static geographic data (such as provinces) with temporal data that’s in the joined table. If we didn’t use the geodatabase the alternative would require a feature layer that had a 1-to1 relationship with the table; in this case, we’d need to duplicate our provinces for each year of population change recorded in the joined table. But that would make for an unnecessarily bulky feature class.
Knowing that, let’s take a look at the steps involved for creating a time animation that leverages a table join with a One-to-Many relationship.
Step 1: Clean up the data
As mentioned previously, the data used to create the animation is stored in two different tables.
One table is the polygon feature class attribute table and the other is a csv table containing the population values to be symbolized, as well as their corresponding year. These time values are stored in a single attribute field and can be used for temporal visualization. Ensure that this data is stored within a single file geodatabase.
It’s important to note that both tables require a common field that can be used as key fields in order for the table join to be created. If a common field is not present, you will need to create a common field in both tables before proceeding.
The attribute table of the Provincial polygon feature class
Also, the ArcGIS Desktop 10.3.1 documentation recommends four best practices for storing temporal data. They include:
The table containing dates which the population of Canada was calculated
- Time values should be stored in a date field type
- Index attribute fields that contain time values
- Use Standard Time for storing time data
Step 2: Create the table join between the polygon feature class and table
After adding the data to the map, right-click the polygon feature class in the Table of Contents, choose Joins and Relates, and then Join. Fill in the parameters of the “Join Data” window. The join field will be the key created to link the province with each population value for a specific year. You can choose to “Validate Join” to check the data for potential join issues caused by invalid characters, have reserved words or non-geodatabase tables. It also informs you on how many records have matched in the join. More information on validating joins can be found here.
If you view the attribute table after completing this join, you will only see a record of the first date comprised in the join. That’s OK, even though the attribute table is limited to showing us the first matched record, it doesn’t mean that the other matched records can’t be used with our animation.
Step 3: Enable time on the polygon feature class using the newly joined date field
To enable time on the data, right-click the polygon feature class in the Table of Contents> Properties>Time tab> ensure Enable time on this layer is checked. A number of parameters will then be exposed. Under Time properties, the Layer Time parameter is chosen to be Each feature has a single time field, as each Province has a single population for each year. The Time Field is named Date in this example, and the Field Format is YYYY to indicate a year. The Time Step Interval for the data used in this example is 5.00 years, and the Layer Time Extent is determined by clicking the Calculate button, which will compute the first and last year of the temporal information of the data. In this example, it was not necessary to change any of the Advanced settings.
The Time tab in the Provincial layer properties dialog window
Step 4: Symbolize polygon feature class off of ‘Values’ field joined from table
Choose the symbology that best represents the data being animated by the time slider. For the population of Canadian provinces over time, a graduated colors quantities symbology was chosen, with a diverse range of colors to better represent the change in the population as time passed. You can also choose to normalize the values, and choose the number of classes to represent the values you are depicting. It really depends on your data.
Figure 1.4: Symbolizing the provincial populations of Canada
Step 5: Use the Time Slider window to start animating your temporal data
The Time Slider window can be opened by clicking the Time Slider button on the Tools toolbar. Your time visualization can be modified by clicking on the Options button in this window.
Parameters used to visualize the temporal data in the Time Slider Options window
The Time Display tab contains parameters to modify the visualization of your data. You can leave the Time zone parameter set to <None> if you don’t want to visualize the data in different time zones; alternatively, setting the time zone will correctly arrange all datasets from different time zones in to one time line. The Time step interval and Time window parameters specify how your animation steps through time. The Time step interval is data specific and controls the intervals in which your Time Slider will progress through each date for your data. The Time window parameter signifies the range of dates that will be displayed with each progression of time steps. For this example, a time step interval of five years and a time window of zero years were used. Finally, the Display date format and Display time format are chosen for the display of the temporal data on the Time Slider.
There are three other tabs in the Time Slider Options window. The Time Extent tab contains parameters to modify the temporal range of the data you are visualization. The Playback tab parameters control the speed and duration of the animation. The duration of playback you input in to the parameter here will control the duration of each frame in the output video. Finally, the Other tab has a parameter for controlling the transparency of the Time Slider window.
Once you’ve chosen your animation parameters you should now be able to play through your animation and you should notice that the animation is leveraging your One-to-Many join even though the attribute table only shows the first matching record.
Step 6: Export animation to a video
Now that you have created an animation of your temporal data, it’s time to export it to a video for use! You can choose to export to an Audio Video Interleaved (.avi) or QuickTime (.mov) video file. After specifying a name for the file as well as the location where you would like to save it, you will be prompted to fill in information regarding the compression of the video. For this example, an AVI video type with Full Frames (Uncompressed) compression type was used. You can find more information on compression properties of Time Slider videos here.
You will now have a video file that can be included in things, such as presentations or embedded in a Web page.
Animation showing provincial populations over time
If you’re interested in visualizing feature layers where the shape and location of each feature changes over time, instructions can be found in the ArcGIS for Desktop Tracking Analyst tutorial.
Do you know of other obscure geodatabase functionality? Share them with us by leaving a comment below.