[GRASS-user] check pixel by pixel

Hamish hamish_nospam at yahoo.com
Wed Oct 3 03:38:24 EDT 2007


> Andruit:
> > I have several raster maps (aspect, slope, tand_curv etc.).
..
> > And then I would like to check Pixel by Pixel 
> > if slope = steep and aspect = North etc.
> > then
> > "Value of the checked pixel" + 10
> >
> > else
> >
> > ....
> >
> > Has anybody done this before? Is it possible to combine several
> > raster maps without losing any information?

sure, it is a basic thing for GRASS probably for 20 years. Combining the
maps into one first is a totally unnecessary step.

Jarosław Jasiewicz wrote:
> Thaw what you described has SpatialGridDataFrame in R. Simply you can 
> import all raster data to one SGDataFrame and you can do there what you 
> need.... It seems, becouse I can't understand for what you need 1 file 
> instead of three or for and use mapcalc for that operation. Simply
> seems that mapalgebra (r.mapcalc) it is what you realy need

e.g. r.mapcalc with the spearfish demo dataset:

g.region rast=elevation.dem
# GRASS usually measures aspect in degrees CCW from East
#  logic:  if(this is true, then do this, otherwise do this)
# "slope", "aspect", and "elevation.dem" are map names.
r.mapcalc "test = if(slope > 10 && (aspect >= 45 && aspect < 135),
                     elevation.dem, null())"
d.rast aspect
d.rast -o test


you can also use create a MASK map if the r.mapcalc logic starts to get
too confusing, to build up your query bit by bit. see the raster intro
page.
  http://grass.ibiblio.org/grass63/manuals/html63_user/rasterintro.html


see also r.mapcalculator for an nice GUI frontend for r.mapcalc.


Hamish




More information about the grass-user mailing list