[GRASSLIST:5930] Re: Mosaicking images with mapcalc

Glynn Clements glynn at gclements.plus.com
Mon Feb 28 05:59:20 EST 2005


Jose Luis Gomez-Dans wrote:

> Working out the average over the whole overlapping region is not hard 
> (r.mapcalc 'rast3=0.5*(rast1+rast2)' does it nicely), but how can I 
> restrict the overlap region? Do I have to use a mask? is there some 
> other way?

It isn't clear what you are trying to achieve.

> Secondly, I have a large number of tiles I want to mosaic (7x7). What's 
> the best way to patch them? Can I just average as I outlined above 
> (i.e., complete_rast=0.5*(rast11+rast12+rast13...rast77)?

Simply computing the mean of 49 maps in one go would probably produce
an all-null map; the only non-null cells would be those where all 49
corresponding input cells were non-null.

I suspect that you need a weighted sum, e.g.:

	complete_rast = eval(\
	k11 = isnull(rast11),\
	k12 = isnull(rast12),\
	...
	k77 = isnull(rast77),\
	k = k11 + k12 + ... + k77,\
	(if(k11,rast11) + if(k12,rast12) + ... + if(k77,rast77)) / k)

However, if each map only overlaps its immediate neighbours, it may be
more efficient to generate a grid of non-overlapping tiles where each
tile would only need data from at most 4 tiles, then patch the
resulting tiles together with r.patch.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list