GRDVECTOR(1gmt) | GMT | GRDVECTOR(1gmt) |

# NAME¶

grdvector - Plot vector field from two component grids

# SYNOPSIS¶

**gmt grdvector** *compx.nc* *compy.nc*
**-J***parameters* [ **-A** ] [
**-B**[**p**|**s**]*parameters* ] [ **-C***cpt* ] [
**-G***fill* ] [ **-I**[**x**]*dx*[/*dy*] ] [
**-N** ] [ **-Q***parameters* ] [ **-R***region* ] [
**-S**[**i**|**l**]*scale*[*unit*] ] [ **-T** ] [
**-U**[*stamp*] ] [ **-W***pen* ] [
**-X**[**a**|**c**|**f**|**r**][*xshift*[**u**]] ] [
**-Y**[**a**|**c**|**f**|**r**][*yshift*[**u**]] ] [
**-Z** ] [ **-f**flags ] [ **-p**flags ] [ **-t**transp ] [
**--PAR**=*value* ]

**Note:** No space is allowed between the option flag and the
associated arguments.

# DESCRIPTION¶

**grdvector** reads two 2-D grid files which represents the
*x*- and *y*-components of a vector field and produces a vector
field plot by drawing vectors with orientation and length according to the
information in the files. Alternatively, polar coordinate *r*,
*theta* grids may be given instead.

# REQUIRED ARGUMENTS¶

**-J***parameters*(more ...)- Select map projection.

# OPTIONAL ARGUMENTS¶

**-A**- The grid files contain polar (r, theta) components instead of Cartesian (x, y) [Default is Cartesian components].

**-B**[**p**|**s**]*parameters*(more ...)- Set map boundary frame and axes attributes.

**-C**[*cpt*|*master*[**+i***zinc*] |*color1,color2*[,*color3*,...]]- Use
*cpt*to assign colors based on vector length. Alternatively, supply the name of a GMT color master dynamic CPT [turbo] to automatically determine a continuous CPT from the grid's z-range; you may round up/down the z-range by adding**+i***zinc*.. Yet another option is to specify**-C***color1,color2*[,*color3*,...] to build a linear continuous cpt from those colors automatically. In this case*color***n**can be a r/g/b triplet, a color name, or an HTML hexadecimal color (e.g. #aabbcc ). If no argument is given to**-C**then under modern mode we select the current CPT.

**-G***fill*- Sets color or shade for vector interiors [Default is no fill].

**-I**[**x**]*dx*[/*dy*]- Only plot vectors at nodes every
*x_inc*,*y_inc*apart (must be multiples of original grid spacing). Append**m**for arc minutes or**s**for arc seconds. Alternatively, use**-Ix**to specify the multiples*multx*[/*multy*] directly [Default plots every node].

**-N**- Do NOT clip vectors at map boundaries [Default will clip].

**-Q***parameters*- Modify vector parameters. For vector heads, append vector head
*size*[Default is 0, i.e., stick-plot]. See VECTOR ATTRIBUTES for specifying additional attributes.

**-R***xmin*/*xmax*/*ymin*/*ymax*[**+r**][**+u***unit*] (more ...)- Specify the region of interest. Specify a subset of the grid.

**-S**[**i**|**l**]*scale*[*unit*]- Sets scale for vector plot length in data units per plot distance
measurement unit [1]. Append
**c**,**i**, or**p**to indicate the measurement unit (cm, inch, or point); if no unit is given we use the default value that is controlled by PROJ_LENGTH_UNIT. Alternatively, use**-Sl***length*[*unit*] to set a fixed plot length for all vectors. Vectors given via plot unit scaling will plot as straight vectors and their lengths are not affected by map projection and coordinate locations. For geographic data you may alternatively give*scale*in data units per map distance unit (see Unit_attributes). Then, your user units are scaled to map distances in the given unit which are projected to plot dimensions. These are geo-vectors that follow great circle paths and their lengths are affected by the map projection and their coordinates. Finally, use**-Si**if it is simpler to give the reciprocal scale in measurement unit per data unit or km per data unit. To report the minimum, maximum, and mean scaled vector length, use**-Vl**.

**-T**- Means the azimuths of Cartesian data sets should be adjusted according to the signs of the scales in the x- and y-directions [Leave alone]. This option can be used to convert vector azimuths in cases when a negative scale is used in one of both directions (e.g., positive down).

**-U**[*label*][**+c**][**+j***just*][**+o***dx*/*dy*] (more ...)- Draw GMT time stamp logo on plot.

**-V**[*level*] (more ...)- Select verbosity level [c].

**-W***pen*- Set pen attributes used for vector outlines [Default: width = default, color = black, style = solid].

**-X**[**a**|**c**|**f**|**r**][*xshift*[**u**]]

**-Y**[**a**|**c**|**f**|**r**][*yshift*[**u**]] (more ...)- Shift plot origin.

**-Z**- The theta grid provided contains azimuths rather than directions (implies
**-A**).

**-f**[**i**|**o**]*colinfo*(more ...)- Specify data types of input and/or output columns.

**-p**[**x**|**y**|**z**]*azim*[/*elev*[/*zlevel*]][**+w***lon0*/*lat0*[/*z0*]][**+v***x0*/*y0*] (more ...)- Select perspective view.

**-t**[*transp*] (more ...)- Set transparency level in percent.

**-^**or just**-**- Print a short message about the syntax of the command, then exits (NOTE:
on Windows just use
**-**). **-+**or just**+**- Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exits.
**-?**or no arguments- Print a complete usage (help) message, including the explanation of all options, then exits.
**--PAR**=*value*- Temporarily override a GMT default setting; repeatable. See /gmt.conf for parameters.

# UNITS¶

For map distance unit, append *unit* **d** for arc degree,
**m** for arc minute, and **s** for arc second, or **e** for meter
[Default], **f** for foot, **k** for km, **M** for statute mile,
**n** for nautical mile, and **u** for US survey foot. By default we
compute such distances using a spherical approximation with great circles
(**-jg**). You can use **-jf** to perform "Flat Earth"
calculations (quicker but less accurate) or **-je** to perform exact
geodesic calculations (slower but more accurate; see PROJ_GEODESIC for
method used).

# GRID FILE FORMATS¶

By default GMT writes out grid as single precision floats in a COARDS-complaint netCDF file format. However, GMT is able to produce grid files in many other commonly used grid file formats and also facilitates so called "packing" of grids, writing out floating point data as 1- or 2-byte integers. (more ...)

# VECTOR ATTRIBUTES¶

Several modifiers may be appended to vector-producing options for specifying the placement of vector heads, their shapes, and the justification of the vector. Below, left and right refers to the side of the vector line when viewed from the start point to the end point of a segment:

**+a**

*angle*sets the angle of the vector head apex [30].

**+b** places a vector head at the beginning of the vector path
[none]. Optionally, append **t** for a terminal line, **c** for a
circle, **a** for arrow [Default], **i** for tail, **A** for plain
open arrow, and **I** for plain open tail. Further append
**l**|**r** to only draw the left or right half-sides of this head
[both sides].

**+e** places a vector head at the end of the vector path
[none]. Optionally, append **t** for a terminal line, **c** for a
circle, **a** for arrow [Default], **i** for tail, **A** for plain
open arrow, and **I** for plain open tail. Further append
**l**|**r** to only draw the left or right half-sides of this head
[both sides].

**+g**-|*fill* turns off vector head fill (if -) or sets
the vector head fill [Default fill is used, which may be no fill].

**+h***shape* sets the shape of the vector head (range
-2/2). Default is controlled by MAP_VECTOR_SHAPE [0].

**+l** draws half-arrows, using only the left side of specified
heads [both sides].

**+m** places a vector head at the mid-point the vector path
[none]. Append **f** or **r** for forward or reverse direction of the
vector [forward]. Optionally, append **t** for a terminal line, **c**
for a circle, **a** for arrow [Default], **i** for tail, **A** for
plain open arrow, and **I** for plain open tail. Further append
**l**|**r** to only draw the left or right half-sides of this head
[both sides]. Cannot be combined with **+b** or **+e**.

**+n***norm* scales down vector attributes (pen thickness,
head size) with decreasing length, where vector plot lengths shorter than
*norm* will have their attributes scaled by length/*norm* [arrow
attributes remains invariant to length]. For Cartesian vectors specify a
length in plot units, while for geovectors specify a length in km.

**+o**[*plon*/*plat*] specifies the oblique pole for
the great or small circles. Only needed for great circles if **+q** is
given. If no pole is appended then we default to the north pole.

**+p**[-][*pen*] sets the vector pen attributes. If
*pen* has a leading - then the head outline is not drawn. [Default pen
is half the width of stem pen, and head outline is drawn]

**+q** means the input *angle*, *length* data instead
represent the *start* and *stop* opening angles of the arc segment
relative to the given point. See **+o** to specify a specific pole for
the arc [north pole].

**+r** draws half-arrows, using only the right side of
specified heads [both sides].

**+t**[**b**|**e**]*trim*[*unit*] will shift
the beginning or end point (or both) along the vector segment by the given
*trim*; append suitable unit (**c**, **i**, or **p**). If the
modifiers **b**|**e** are not used then *trim* may be two values
separated by a slash, which is used to specify different trims for the
beginning and end. Positive trims will shorted the vector while negative
trims will lengthen it [no trim].

In addition, all but circular vectors may take these modifiers:

**+j**

*just*determines how the input

*x*,

*y*point relates to the vector. Choose from

**b**eginning [default],

**e**nd, or

**c**enter.

**+s** means the input *angle*, *length* are instead
the *x*, *y* coordinates of the vector end point.

Finally, Cartesian vectors may take these modifiers:

**+z**

*scale*[

*unit*] expects input

*dx*,

*dy*vector components and uses the

*scale*to convert to polar coordinates with length in given unit.

# EXAMPLES¶

To draw the vector field given by the files r.nc and theta.nc on a linear plot with scale 5 cm per data unit, using vector rather than stick plot, scale vector magnitudes so that 10 units equal 1 inch, and center vectors on the node locations, run

gmt grdvector r.nc theta.nc -Jx5c -A -Q0.1i+e+jc -S10i -pdf gradient

To plot a geographic data sets given the files comp_x.nc and comp_y.nc, using a length scale of 200 km per data unit and only plot every 3rd node in either direction, try

gmt grdvector comp_x.nc comp_y.nc -Ix3 -JH0/20c -Q0.1i+e+jc -S200k -pdf globe

# NOTES¶

Be aware that using **-I** may lead to aliasing unless your
grid is smoothly varying over the new length increments. It is generally
better to filter your grids and resample at a larger grid increment and use
these grids instead of the originals.

# SEE ALSO¶

gmt, gmtcolors, grdcontour, plot

# COPYRIGHT¶

2019, The GMT Team

September 7, 2019 | 6.0.0rc4 |