[GRASS5] r.mapcalc question
David Piasecki
piasecda at nv.doe.gov
Wed Feb 2 16:29:48 EST 2005
Actually, I'm starting to think r.null may work for this purpose. Since
each image is completely separate from the others, there is no overlap,
and I can combine them all in 2 commands instead of 42.
Thanks,
David
On Feb 2, 2005, at 12:37 PM, Paul Kelly wrote:
> On Wed, 2 Feb 2005, David Piasecki wrote:
>
>> r.mapcalc
>> 'calc.red=if(isnull(image0.red),image1.red,if(isnull(image1.red),image
>> 0. red))'
>>
>> That's great; however, I have 42 images. So I tried some logic...
>> r.mapcalc 'calc.red=( image0.red || image1.red )'
>> r.mapcalc 'calc.red=( image0.red + image1.red )'
>>
>> I think these aren't working because GRASS has a problem evaluating
>> these expressions since image0.red is null wherever image1.red is not
>> null. However, no error messages are given. Is there an easier way to
>> do this than the first command given above?
>
> Assuming none of your non-NULL cells have a value of 0, perhaps
> convert all the nulls to 0 using r.null? What you have written
> probably would have worked in GRASS 4 before NULLs were introduced. In
> GRASS 5, if any of the input maps for a cell in r.mapcalc are null
> then the output cell is null.
>
> Something like
> r.null image0.red null=0
> r.null image1.red null=0
> might do what you want. But your first way is more correct IMHO and
> probably the way it should be done.
>
> Paul
>
More information about the grass-dev
mailing list