[GRASS5] r.mapcalc question

David Piasecki piasecda at nv.doe.gov
Wed Feb 2 16:19:43 EST 2005


Yeah, I'm not sure if the r.null thing will work since the images are  
of adjacent coordinates. I'm trying to build a big map out of smaller  
ones, and I was looking for something faster than r.patch.

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