Animating data is a very good way to display and share your data. There are various ways to do this, although with very large data files some do become very slow/impossible. Here I'm going to assume that your input data is in 2D NetCDF format with a time axis of some kind (e.g. day numbers, years).
1. COMBINING A SET OF IMAGE FILES
The first method involves essentially exporting a set of image frames (using a consistent colour map/palette) and then using separate software to combine those frames into a media file (20-25 frames/sec is a usual frame rate, so this usually involves quite a lot of files). This essentially splits the process into two steps: Step 1: Split the NetCDF input into image frames (which you usually do from whatever package you have used to read in the data, e.g. Python) |
Step 2: Options - combine the image frames into a movie file:
- in Python using the 2D plotting library matplotlib (see here and/or here and/or here).
A good example page for this and MoviePy is here. A worked example from WeatherForce using ECMWF data is here.
Note that some of these matplotlib options can generate animations 'on the fly', i.e. without having to do Step 1.
- Using ImageMagick (see e.g. advice here), e.g. commands like:
convert -loop 0 -size 1400x700 -delay 10 pngfiles/*.png output.mp4
to create a movie called output.mp4 (at resolution 1400x700 pixels).
- Using FFmeg (see example here), e.g. commands like this:
mkdir temp
convert *.jpg –delay 10 temp/%05d.jpg
ffmpeg –I temp/%05d.jpg output.mp4
to create a movie called output.mp4
- in Python using the 2D plotting library matplotlib (see here and/or here and/or here).
A good example page for this and MoviePy is here. A worked example from WeatherForce using ECMWF data is here.
Note that some of these matplotlib options can generate animations 'on the fly', i.e. without having to do Step 1.
- Using ImageMagick (see e.g. advice here), e.g. commands like:
convert -loop 0 -size 1400x700 -delay 10 pngfiles/*.png output.mp4
to create a movie called output.mp4 (at resolution 1400x700 pixels).
- Using FFmeg (see example here), e.g. commands like this:
mkdir temp
convert *.jpg –delay 10 temp/%05d.jpg
ffmpeg –I temp/%05d.jpg output.mp4
to create a movie called output.mp4
2. EXPORTING FROM A GIS PACKAGE:
A very good alternative is to use a GIS package. This way you have the (in my view) critical advantage that you can overlay a shapefile over your images and this allows you to put e.g. country/state borders on your map very easily. In fact, all the many items of 'map furniture' that you can put on using a GIS package (e.g. legends, image overlays, labelling of e.g. cities, regions, applying a buffer around a region) can easily be included, but I think it's fair to say that plotters such as Python or R are quite clunky at doing that sort of thing. |
Using Panoply is probably the easiest option, although warning: the final result comes out quite fuzzy so this is for a quick look-see only (Panoply isn't really a GIS package, but included here because it's also not like the other option above).
- Load in the NetCDF file and display a Geo2D plot. Then Overlay tab -> overlay MWDB_Coasts_Countries_3.cnob . Zoom in to the area of interest, File -> Export Animation ... -> Change Format to "AVI Video" and select frame rate 1/sec and the right animation dimension -> Wait for the progress bar at the bottom to complete.
Using ArcGIS Time Slider and Animation Manager:
Follow these steps:
1. Open ArcGIS
2. Activate hardware acceleration if you can: see here.
3. Search through your Map document and check that you do NOT have any other time-enabled layers. If you do and they cover a different time extent, safest to move them to another Map document, close and restart ArcGIS.
3. Use ArcToolbox -> Multidimension Tools -> Make NetCDF Raster Layer to import your NetCDF file (choose lon and lat as X and Y, put your time variable as a Dimension Value and make sure the Value Selection Method is BY_VALUE). Zoom to the layer.
4. Right click on the new layer in the Table of Contents -> Properties... -> Symbology -> Make zero a background value (if necessary).
5. Right click on the new layer in the Table of Contents -> Properties... -> Time tab -> Enable time on this layer (check you have selected "Layer has time as a dimension") and choose your time variable as the time dimension, then click "Calculate" and then change the time step interval if necessary (the 'Calculate' usually comes up with something not quite correct for your data) and put the Time Zone as UTC for subdaily timesteps or leave as <Null> otherwise (e.g. for CaMa-Flood data I had Field Format YYYY, Time Step Interval 1 day and Time Offset 0.00) -> OK (do NOT check "Data changes frequently so calculate time extent automatically").
- NOTE AT THIS POINT: if your data is coming from a NetCDF file that does not have a CF compliant time variable, then you will save hours of wrestling (and most likely failing) with ArcGIS if you stop now, create that time variable in the NetCDF file and reimport the data. For example, I had 276 months of data where the time axis was called monthnum and there was no corresponding dimension variable. NCView is happy to display that, but ArcGIS falls over and crashes because it can't interpret what those times mean. I found I could only make a movie out of this when I had renamed that dimension to time and inserted a variable like this:
float time(time) ;
time:long_name = "time" ;
time:units = "seconds since 1992-1-1 00:00:00" ;
If you do that, you should find that the 'Calculate' function above does actually return the right answer too.
- Now the Time Slider is enabled top right (small icon that looks like a page with a clock on it). Click on that -> If it says "Time is disabled on this map" then click the icon furthest left (with the clock on it) to enable. Now click on the Time Slider Options icon left -> there are quite a few options in here that you need to make sure are right for your data:
- Time Slider Options -> Time Display: set time zone to UTC for subdaily data or <Null> otherwise, make sure the Time window is zero (0.0) - Yes ZERO not ONE - choose a date and time format that you're happy with and select "Show time on map display" (n.b. it will show on the map, but I can't find any option to export it also in the video file generated below). Finally, click on "Appearance" and make it so that the time stamp anchor point is somewhere innocuous.
- Time Slider Options -> Time extent: Sometimes ArcGIS guesses the time extent incorrectly. If so, select "Restrict full time extent to" <Undefined> here and put in the actual start and end times of your data.
- Time Slider Options -> Playback tab: if you want to have the number of frames match the number of timepoints actually in your data (e.g. 365 days), then choose "Display data for each timestamp" and put the slider on slowest. Alternatively, if you select "Play in specified duration" (e.g. =30 sec) then ArcGIS will combine that with the default frame rate (which is not changeable but fixed at 20 frames/sec) and deduce that the number of frames for your animation will be the product of those two (e.g. 600 frames).
Click "OK". Note that if you have more than one time-enabled layer in your map, the Time Slider options will apply to all of those layers.
- Click on a couple of time points in the slider just to make sure that the image changes over time (i.e. it is not stuck on time step #1), then make sure the Time Slider slider is positioned on the first timestep.
6. Next, set up the view of the ArcGIS window carefully. The export will be whatever is in the view of ArcGIS, so carefully zoom to the layers you want and make the ArcGIS window as large as possible x and y so that you get as many pixels as possible in the output (it will not automatically give you the native resolution of your layers: if your ArcGIS window is small then your output will be low resolution!). I suggest to close all toolboxes and minimise the size of the table of contents on the left too.
(n.b. if you have >1 screen, DO NOT spread the window over more than one screen: for some reason the final movie comes out crazy if you do that).
7. DO NOT click the icon that looks like a section of old-style Super 8mm movie reel just to the right of the Time Slider Options on the Time Slider (doing that just seems to give me a single frame copied over the length of the 'movie', which is odd and definitely not what I ever need). INSTEAD, CLOSE the Time Slider.
- Now SAVE YOUR MAP
- Next, open the Animation toolbar using Customize -> Toolbars -> Animation, then Animation -> Animation Manager -> Remove all Keyframes and Tracks, then Animation -> Create Time Animation -> OK. Animation -> Export Animation... to export the animation:
- Select filename (choose filetype .avi), but BEFORE CLICKING EXPORT click to open the Options... far bottom right and select "Enable Off-Screen recording" (which I think is what allows the export to continue while your screensaver is on, if you have one). Video Resolution: Leave this unchecked - easier to crop the final movie file outside ArcGIS. Frame-based video support: Leave this also unchecked - also easier to trim the final movie file if you need to (you cannot change the frame rate here).
- You are ready to start the export, but UNFORTUNATELY from experience I have found (with ArcGIS 10.6.1) that if your computer is doing anything else while ArcGIS is working then the video creation will not come out right (e.g. it takes 2 hrs to make a file of the right length, but all frames turn out to be copies of the first one). You just need to reserve yourself a time when you can leave the computer doing the export without any interference (e.g. overnight or in the evening) and just let it do it.
Click "OK" and "Export".
8. A window appears with some options for Video Compression (WAIT until it redraws the map in the background before you click anything). Make sure the Compression Quality is 100 (lossless). The other options are described here but I think you can leave them on their defaults (except I usually make it so that there is a Keyframe every frame, even though I am not sure what this does ...). Click "OK" and the export process will begin.
As with many ArcGIS functions, exporting is difficult to abort (you may have to use Task Manager and abort the whole program). It may actually be easier simply to leave ArcGIS going behind your other windows and delete the output. The Time Slider dialogue will reappear when the export is complete.
Another example of using the Time Slider is here.
Note that a significant limitation of ArcGIS is that although it can load in and display data that is at higher resolution than what you can see on the screen, the program can only export animations from what is actually viewable on your screen, i.e. even if your base data is at higher resolution than your screen is capable of displaying, what will appear in your video is the resolution of your screen, not your data (see here).
Note that all of these options are to create a straight rectangular video of a particular area. If you would like to produce an image but then also wrap the output around a globe then that can be done too (e.g. in R using mapmate).
Finally, note that if you want to insert a movie file into a powerpoint presentation, you'll need first to convert the file to .mpeg (e.g. using an online converter like this one). You can also display movies on a globe in Google Maps, but to do that you will have to produce a .kml/.kmz file rather than a straight movie file (see here for advice on this option).