[GRASS-user] How to plot a vector field?

Hamish hamish_b at yahoo.com
Thu Jun 27 17:07:31 PDT 2013


David wrote:

> I would like to plot data which consist of a number of points, each of 
> which has a latitude, a longitude, an x-velocity, and a y-velocity.  I 
> want to plot an arrow for each point that starts at the proper latitude 
> and longitude, and has a length and direction that show the velocity.  I 
> used to think of these as vector values, but in GRASS a vector is 
> something else.  What is the proper GRASS terminology for this kind of 
> data?  What modules do this kind of plot?

Hi,

use the d.barb module from GRASS 6 addons.
  http://grasswiki.osgeo.org/wiki/AddOns/GRASS_6#d.barb

x and y components of velocity are given using attribute column names
in the u= and v= parameters when a GRASS vector (i.e. sparse points)
input= map is given.

"vector maps" mean defined by coordinates, so points, lines, and areas.
"raster maps" mean defined by 2D or 3D array, so constant grids and pixels.

d.barb will work with both GRASS raster and vector points maps,
the meaning of the u=, v= parameters changes according to the context.


Usage:
 d.barb [-r] [direction=name] [magnitude=name] [u=name] [v=name]
   [input=name] [layer=value] [style=string] [color=name] [skip=value]
   [scale=value] [peak=value] [aspect_type=string]
   [legend_at=x,y[,x,y,...]] [legend_velo=value[,value,...]]
   [legend_fontsize=value] [--verbose] [--quiet]

Flags:
  -r   Rotate direction 180 degrees
        Useful for switching between atmospheric and oceanographic conventions
 --v   Verbose module output
 --q   Quiet module output

Parameters:
        direction   Raster map (or attribute column) containing velocity direction
        magnitude   Raster map (or attribute column) containing velocity magnitude
                u   Raster map (or attribute column) containing u-component of velocity
                v   Raster map (or attribute column) containing v-component of velocity
            input   Name of input vector map
            layer   Layer number
                     A single vector map can be connected to multiple database tables. This number determines which table to use.
                    default: 1
            style   Style
                    options: arrow,barb,small_barb,straw
                    default: arrow
            color   Color
                     Either a standard color name or R:G:B triplet
                    default: black
             skip   Draw arrow every Nth grid cell
                    default: 10
            scale   Scale factor for arrow rendering
                    default: 1.0
             peak   Maximum value for scaling (overrides map's maximum)
      aspect_type   Direction map aspect type
                    options: cartesian,compass
                    default: cartesian
        legend_at   Screen percentage for legend barb ([0,0] is bottom-left)
                     Draws a single barb and exits
                    options: 0-100
                    default: 10.0,10.0
      legend_velo   Velocity for legend key arrow
  legend_fontsize   Font size used in legend
                    default: 14


it's still a work in progress, but ~90% of the features are working.

Hamish



More information about the grass-user mailing list