X

NV5 Geospatial Blog

Each month, NV5 Geospatial posts new blog content across a variety of categories. Browse our latest posts below to learn about important geospatial information or use the search bar to find a specific topic or author. Stay informed of the latest blog posts, events, and technologies by joining our email list!



New ENVI Agent, IDL Agent, and GeoAgent Quick Guides

New ENVI Agent, IDL Agent, and GeoAgent Quick Guides

6/9/2026

The recent release of ENVI® Agent, IDL® Agent, and GeoAgent™ revolutionize how users interact with geospatial software. These agentic AI applications act as partners to plan, simplify, and execute complex workflows. Knowing where to start can be challenging for new users. To this end, we developed three new quick guides to... Read More >

Introducing NISAR Data Support

Introducing NISAR Data Support

6/5/2026

The release of ENVI® SARscape 6.3 in April 2026 includes preliminary support for NASA-ISRO SAR (NISAR) data. The NISAR mission is a joint Earth-observing satellite project between NASA and the Indian Space Research Organization designed to monitor changes in the planet’s land and ice surfaces using advanced radar imaging. It... Read More >

Monitoring Illegal Mining in the Amazon: Turning Persistent Data Into Actionable Insight

Monitoring Illegal Mining in the Amazon: Turning Persistent Data Into Actionable Insight

5/28/2026

Illegal mining over decades has constituted one of the most persistent and complex socio-environmental problems in the Brazilian Amazon. In recent years, with the increasingly intensive use of mechanized extraction, the associated environmental impacts—such as deforestation, intense soil disturbance, river siltation, and mercury... Read More >

From Answers to Action: Why ENVI and IDL Agents Go Beyond General AI

From Answers to Action: Why ENVI and IDL Agents Go Beyond General AI

4/20/2026

As generative AI tools like Claude and Gemini continue to gain traction, many organizations are asking the same question: Can general purpose AI actually support real geospatial workflows, or does it stop at surface-level answers? That question was front and center in our recent webinar, Meet Your New Partners in Science: ENVI... Read More >

Mapping Earthquake Deformation in Taiwan With ENVI

Mapping Earthquake Deformation in Taiwan With ENVI

12/15/2025

Unlocking Critical Insights With ENVI® Tools Taiwan sits at the junction of major tectonic plates and regularly experiences powerful earthquakes. Understanding how the ground moves during these events is essential for disaster preparedness, public safety, and building community resilience. But traditional approaches like field... Read More >

1345678910Last
«June 2026»
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
15782 Rate this article:
4.5

Guest Request - How to create an animated plot video

Jim Pendleton

Very recently I had the opportunity to go for a hike here in Boulder with a friend from my college years.  He's now a successful scientist, using IDL since about 1985.  I sense causality.

Of course, since we're both science and software geeks, the topic of conversation rapidly devolved from family and the rejuvenating power of nature, to general health topics for 40-somethings, and coding quandaries.

He had a practical question for me.  "Let's say I want to animate a plot and programmatically generate a video for a presentation.  Is this easy to do in IDL these days?"

He'd not studied the What's New sections of the IDL documentation for a couple releases.  Science takes precedence, and his impressions were based on the now-obsolete MPEG_WRITE functionality.

The answer of course is that IDL now makes this task very simple, indeed. Here is a quick example, animating a simple sine wave plot.

(Recall that as of 8.3, you can copy and paste lines including the IDL prompt from this web page to the Workbench IDL Console, and the "IDL>" string will be stripped automatically.)

First, generate your wave form using the PLOT function.

IDL> x = findgen(361)*!dtor
IDL> y = sin(x)
IDL> p = plot(x, y)

For this exercise, we'll generate an output MPEG-4 file in your temporary directory.

IDL> file = filepath('test.mp4', /tmp)

We'll use the Plot::CopyWindow method to scrape the bitmap from the plot graphic.  This is returned in exactly the shape the WRITE_VIDEO procedure requires as input.

If you are generating output using Direct Graphics, the equivalent action is to call the function TVRD(TRUE=1) .  And if you are using Object Graphics, get the IMAGE_DATA property from your destination object, such as an IDLgrWindow.

IDL> write_video, file, p.copywindow(/antialias), handle = handle, $
IDL>        format = 'mp4', video_fps = 30

We've now written the first frame of our video.

Here, we've specified the format explicitly as MPEG-4 and the playback rate for the video as 30 frames per second.  On the first call to WRITE_VIDEO the HANDLE keyword is an output.  We will use it as input when writing the remainder of our frames.

Let's loop over 360 degrees by a single degree and update the plot at each step.  Our animation will produce about 12 seconds of video in playback.  (361 frames/30 frames per second.)

IDL> for i = 0, 359 do begin & $
IDL>    y = shift(y, 1) & $
IDL>    p.setdata, x, y & $
IDL>    write_video, file, p.copywindow(/antialias), handle = handle & $
IDL> endfor

Once we have written all our frames, explicitly close the video file to commit the changes.

IDL> write_video, /close, handle = handle

If you're running an OS that understands file associations, you should be able to simply SPAWN the file from IDL to verify its playback.

IDL> spawn, file, /hide

That was indeed easy.

If you want to "slow down" your animation at a critical point for highlighting, simply write a single image buffer multiple times.  For example, you might add this code snippet to slow down the animation during playback's central frames:

    if (i gt 90 && i lt 270) then begin
        for j = 0, 3 do begin
            write_video, file, p.copywindow(/antialias), handle = handle
        endfor
    endif

The WRITE_VIDEO procedure is a wrapper for the IDLffVideoWrite class which in turn wraps the popular open-source FFmpeg library.  WRITE_VIDEO provides options for writing an audio stream to your video as well.

In the online help, see the note on "Replacing the FFmpeg Version" in the Creating Video topic if you need to write your animations in a format whose support is outside the defaults in IDL, such as H.264 video format or MP3 audio.

 

Please login or register to post comments.