[GRASSLIST:4140] Re: Newbie Q re: r.mapcalc
glynn.clements at virgin.net
Tue Jul 23 16:43:42 EDT 2002
Victor Wren wrote:
> I have been attempting to go through the Grass Seeds tutorial, and I
> have a feeling I'm missing something very fundamental.
The "GRASS Seeds" tutorial was written for GRASS 4.x. There are
significant differences between 4.x and 5.0, one of which is the
handling of "no data" areas.
> On the route
> cost analysis (which is going to be key to the project I'm working on),
> I'm having an inordinate amount of trouble with what should be an
> absurdly elementary step:
> r.mapcalc 'asp_cost = asp_north + asp_south'
> asp_north and asp_south are mutually exclusive rasters. The addition
> of the two results in a raster with all elements equal to "no data"
Most r.mapcalc operators and functions return null (signifying "no
data") if any of their arguments are null.
GRASS 4.x didn't support a distinguished null value. Instead, programs
tended to use zero for no data.
 IIRC, the only functions which can return a non-null value when
given a null argument are eval(), if() and isnull().
> I have no masks in effect. I have tried boolean operators
> ( asp_cost=if(asp_north,asp_north,asp_south) ), addition of constants,
> anything I can to get past this, with no success -- a "no data" stays "no
> data" no matter what I do to it. If I combine two maps with non-
> overlapping data, all the "no data" cells combine, resulting in an empty
> map. Best I can manage is getting asp_cost to equal asp_north OR
> asp_south, but not both combined.
If you just want to combine disjoint rasters, use r.patch. OTOH, if
you actually want to perform arithmetic addition, either use modify
the existing maps using r.null, or generate a new maps using e.g.
r.mapcalc 'asp_north_2 = if(isnull(asp_north),0,asp_north)'
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-user