# Animation from grid data/files:

**URL:** https://discourse.julialang.org/t/animation-from-grid-data-files/114277
**Category:** Visualization
**Tags:** geospatial, geodesy
**Created:** [May 15, 2024, 12:24am UTC](https://discourse.julialang.org/t/animation-from-grid-data-files/114277 "2024-05-15T00:24:11Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![GeodeticR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/geodeticr/32/218661_2.png) [@GeodeticR](https://discourse.julialang.org/u/GeodeticR)
#### Post date: [May 15, 2024, 12:24am UTC](https://discourse.julialang.org/t/animation-from-grid-data-files/114277/1 "2024-05-15T00:24:12Z")

</div>

Making an animation with the GMT.jl package is not intuitive to me and I would love some guidance/direction on how to achieve my end goal.

Luckily, though, using the GMT.jl package to plot a static grid is relatively straight forward, as it is only a few lines of code, shown below.

```julia
using DataFrames, DelimitedFiles, Glob, GMT,

epoch1 = readdlm("/home/rob/Documents/julia/Vgrdimg/51915_Vgrdimg.txt");

G = gridit(epoch1[:, [1, 2, 3]],
        mask = 0.3, V = :q);
grdimage(G, shade = true, coast = (ocean = :gray, shore = 0.5), fmt= :png, show, = true);

```

Which produced this image:

 ![grid_gmt](https://global.discourse-cdn.com/julialang/original/3X/d/6/d602a7a5232df332f10778b02ffb66c25c8d31ac.png)

And, it’s fine. Ideally, I would like the resolution of the gridding to be finer, like this plot I made in Python, but, I couldn’t get the masking to work in the eoMaps package.

 ![sigma2_new](https://global.discourse-cdn.com/julialang/original/3X/b/a/baa735bae110600574ac413d33ab50a730a77985.png)

But I digress.

I tried to create a loop that would iterate through all my files, of which I have 1821, and each file is a timestep. So, I wanted to read the first 3-columns of the file, and then feed them into the `movie()` function in GMT, but I know I’m not doing it right, and I can’t figure out exactly what I’m supposed to do to get an animation to work.

Here is what I’ve attempted so far:

```julia
epoch1 = readdlm("/home/rob/Documents/julia/Vgrdimg/51915_Vgrdimg.txt");
file = "/home/rob/Documents/julia/Vgrdimg/"

function main_sc()
    for (i,file) in enumerate(glob("*.txt", file))
        file_hold = readdlm(file)

        G = gridit(file_hold[:, [1, 2, 3]],
        mask = 0.3, V = :q);

        fig = grdimage(G, shade = true, coast = (ocean = :gray, shore = 0.5), fmt= :png);

        #movie(main_sc, name=:count, frames = 100, format = :mp3, frame_rate = 16, clean = true );
        
    end
end
movie(main_sc, name=:count, frames = 100, format = :mp4, frame_rate = 16, clean = true );

```

Any help would be greatly appreciated. Thank you!

---

_[View the full topic](https://discourse.julialang.org/t/animation-from-grid-data-files/114277)._
