[GRASS5] r.mapcalc question

David Piasecki piasecda at nv.doe.gov
Wed Feb 2 17:23:43 EST 2005


Hmmm... maybe r.null isn't such a good idea after all. Turns out that  
because my small images do not encompass the full extent of the region,  
adding them together after doing an r.null on the large map doesn't  
work. The null values creep in from all the small images. Dang! Well, I  
guess I'll think of something.

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