Add vector that originates at lon/lat and that only point West or East:

Hi all;

I am having trouble figuring out how to plot vectors that will only point either West or East, which the size of the arrow corresponds to the value I have.

I have the longitude and latitude I want to plot them at, and if the value is positive, I want it to point east, and if the value is negative, I want the arrow to plot point west. After reading the documentation on Arrows, it’s not clear to me how I would go about this.

What I’m trying to do is combine my two plots, into a single one for a nicer animation that indicated magnitude and direction of the Eastward component while also indicating the vertical displacement by circle fill color.

I’m just not sure how to accomlish this. I have about 1826 still frames like this and I’m ussing ffmpeg to string them together for a nice smooth animation.

In my head, I want each vector to come out of each circle that represents a GPS station, and then change in size and direction depending on the +/- value, and the magnitude of that value as well. It’s all in mm/yr.

Does anyone have any idea of how I can accomplish this? I’m going to modify the code below that was used to create the plot above.

file_count = 1

for i in zip((glob("*.csv", vertpath)), (glob("*.csv", eastpath)))
    
    #vert, east, lonlatvert, lonlateast = csv_read(i)
    #vert, east = csv_read(i)

    vert = CSV.read(i[1], DataFrame)
    east = CSV.read(i[2], DataFrame)

    vert.sigma .= coalesce.(vert.sigma, 0.0)
    east.sigma .= coalesce.(east.sigma, 0.0)

    base = basename(i[1])
    yr = string(base[1:9])
    
    count_up = lpad(file_count, 4, "0")

    GMT.subplot(grid = "2x1", savefig = imgpath * "$count_up" * "_stack.png",); 
    
        GMT.basemap(region= [-130 -70 24 51], proj = (name = :lambertConic, center = [-100 35], parallels = [33 45]),
            coast = (borders = ((type = 1, pen = ("thick", "black")), (type = 2, pen = ("thinner", "lightgrey"))),
                area = 500,
                shore = (:thinnest, :lightgrey)),
            panel = (1,1),
            title = "Vertical Displacement | $yr"
        );

        
        GMT.basemap(region = [-130 -70 24 51],
            proj = (name = :lambertConic, center = [-100 35], parallels = [33 45]),
            coast = (borders = ((type = 1, pen = ("thick", "black")), (type = 2, pen = ("thinner", "lightgrey"))),
                area = 500,
                shore = (:thinnest, :lightgrey)),
            panel = (2,1),
            title = "Eastward Displacement | $yr"
        );
        

        colorbar!(position = (outside = true, anchor = :MR), xaxis = (annot= :auto, ticks= :auto),
        ylabel = "mm", cmap = roma);    

        GMT.scatter!(lonlat, vert.window_ave .* 10,
            zcolor = vert.window_ave .* 10,
            cmap = roma,
            marker = :c,
            markersize = 0.13,
            panel = (1,1)
        );

        GMT.scatter!(lonlat, east.window_ave  .* 10,
            zcolor = east.window_ave .* 10,
            cmap = roma,
            marker = :c,
            markersize = 0.13,
            panel = (2,1)
        );


    subplot(:end)
    file_count += 1
    
end

any help or input would be greatly appreciated, and thank you in advance!

  • Rob

GMT plot -Sv or -SV. One uses the coordinates + angle + amplitude (x,y,angle,magnitude), the other the coordinates + components (x,y,dx,dy).
In you case the former is better I guess.
Create a file with lon lat 90 value_eastward_displacement then plot it.

Once you have a figure you like, gmt movie might be of help for the animation part :slight_smile:

Awesome, thank you! Going to try this out now :slight_smile:

Thank you again for your help. I was able to create the vectors on top of the plot to get the sense of direction.

I have one more quesiton, if you don’t mind. The plotting is rather chaotic since it’s plotting the direct values and there is not color scale to help smooth out the variation. Is there a way to “smooth” the vector direction? Like, if the value is between 0.25 - 0.29, or something of the like, that the length of the vector doesn’t change in magnitude?

I think that would really help with giving a nice animation to look at.

Here is the video to better visualize what I mean.

Thanks again!

  • Rob

Depending on what to want to achieve, there are several options I can think of :

  1. Filter the data or add more frames (interpolate) (cf. filter1d, regress, sample1d)
  2. Play with vector attributes: +c, +n

One comment, the color evolution is difficult to notice, I’d add a small panel with the time-series of at least one point :slight_smile: