grads

How to draw a square in GrADS?


I am looking for a command line that allows to draw a square in my plot in GrADS. Here is an example

Example

I would like to get a command line which allows me to draw a square like the one that I show on my picture example.


Solution

  • I assume the boundaries of the square you want to draw are based on lat/lon coordinates, and the bottom left corner is at (4N, 74W) and the upper right corner is at (8N, 72W). The following script fragment should work, but you must draw the plot first in order to set up the scaling between world coordinates and X,Y location on the page.

    'q w2xy -74 4'  
    xpos1=subwrd(result,3)
    ypos1=subwrd(result,6)
    'q w2xy -72 8'
    xpos2=subwrd(result,3)
    ypos2=subwrd(result,6)
    'set line 2 1 6'  '* a thick, red line
    'draw rec 'xpos1' 'ypos1' 'xpos2' 'ypos2
    

    This is what it looks like if you are working with GrADS interactively:

    ga-> q w2xy  -74 4   
    X = 4.77083  Y = 3.08333
    ga-> q w2xy  -72 8
    X = 5.74306  Y = 5.41667
    ga-> set line 2 1 6
    SET LINE values:  color = 2  style = 1  thickness = 6
    ga-> draw rec 4.77083  3.08333 5.74306  5.41667