[GRASSLIST:5887] Mosaicking images with mapcalc

Hi!
I have a number of raster (FCELL) datasets over a large area. I am
trying to mosaic these into a single raster file, but I don't know how
to approach some tings.

The individual rasters do have some overlap, and I
want to have a smooth overlap region (one that is not visible). Over the
entire overlap region, most of the differences are very small (this is
expected), but towards the edges, they start to raise. I would like to
just combine the two raster over the central 60% of the overlap region,

As an example, let's assume that we only have an overlap in the NS
region, raster1 goes from -700 to 100, and raster2 from 0 to 800. The
overlap region is thus 0 to 100. I would like to patch these two
rasters so that the resulting raster (raster3) goes from -700 to 800,
and that the value between 20 and 80 is the average of rast2 and rast1.

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?

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)?

Many thanks!
Jose

--
Jose L Gomez-Dans, Research Assistant
Bristol Glaciology Centre, Geographical Sciences/CPOM
University of Bristol, Bristol, UK

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@gclements.plus.com>