GRASS logo

NAME

g.region.point

DESCRIPTION

g.region.point resets the computational region to a square box around a given coordinate at the current resolution. It is intended for use within GRASS scripts to speed up processing by limiting expensive raster calculations to a small area of interest.

NOTES

To preserve the original region settings this module should generally be used in tandem with the WIND_OVERRIDE environment variable.

If the new region bounds do not line up with a multiple of the map resolution the bounds will be extended outwards, preserving the region resolution.

If the -z flag is used, then in the case of a bounds/resolution incompatibility the resolution will be altered and the region bounds preserved. The -z flag requires that a value is given for the resolution option.

EXAMPLE

The following is a shell script utilizing g.region.point which will evaluate the mean value in a 100m wide raster buffer around a series of vector points. Using g.region.point speeds up this script about 700% while producing identical output.
  #!/bin/sh
  # Spearfish dataset

  # maps to use in query
  VECT_MAP=archsites
  RAST_MAP=elevation.10m

  # set region from target raster
  g.region rast="$RAST_MAP"

  # clone current region
  g.region save="tmp_region.$$"

  # set temporary region storage
  WIND_OVERRIDE="tmp_region.$$"
  export WIND_OVERRIDE

  # output column headings line
  echo "cat|mean_elev|n"

  # run the processing loop
  v.out.ascii "$VECT_MAP" | ( while read LINE ; do
     POINT=`echo $LINE | cut -f1,2 -d'|' | tr '|' ','`
     CATEGORY=`echo $LINE | cut -f3 -d'|'`

     g.region.point coord="$POINT" diam=150 res=10
     r.circle -b coord="$POINT" max=100 out=MASK --quiet
     eval `r.univar -g "$RAST_MAP"`
     g.remove MASK --quiet
     echo "$CATEGORY|$mean|$n"
  done )

  # remove the temporary region
  unset WIND_OVERRIDE
  g.remove region="tmp_region.$$" --quiet
The v.db.update module may be used in place of "echo" in the above example to load the results into the vector map's attribute table instead of sending them to stdout. If required a new column to hold these values may be added to the database table with v.db.addcol prior to running the update script.

SEE ALSO

g.region, v.rast.stats
GRASS Variables

AUTHOR

Hamish Bowman, Dunedin, New Zealand

Last changed: $Date$


Main index - general index - Full index

© 2003-2016 GRASS Development Team