[GRASS-user] Re: r.mapcalc changes color table

Glynn Clements glynn at gclements.plus.com
Fri Nov 27 19:39:31 EST 2009


Tim Michelsen wrote:

> >>> 6) use r.mapcalc to cut: r.mapcalc "cut=if(boundary_raster, large_map,
> >>> null())"
> >>
> >> Replace step 6 with:
> >>
> >>     g.copy rast=boundary_raster,MASK
> >>     r.resample input=large_map output=cut
> >>     g.remove rast=MASK
> >>
> > 
> > Can someone perhaps explain why steps 4 and 5 are necessary?
> > (My understanding is that r.mapcalc anyway observes the region settings)
> > 
> > 
> > Couldn't step 6 be simplified to:  r.mapcalc cut = large_map
> > ?
> I don't know. That was the approach I have always seen and been told.
> 
> The question is:
> when do I use r.resample and when do I use r.mapcalc to cut a smaller
> portion from a large raster map?

"r.mapcalc 'cut = large_map'" is equivalent to "r.resample in=large_map out=cut".

> from the man page:
> The method by which resampling is conducted is "nearest neighbor" (see
> r.neighbors). The resulting raster map layer will have the same
> resolution as the resolution of the current geographic region (set using
> g.region).
> 
> I actually do not want to extract by sampling than rather copy a smaller
> area from the large map.

If the current region has the same resolution as the input map, then
there will be a 1:1 correspondence between input cells and output
cells.

All raster modules perform nearest-neighbour resampling, as the
underlying GRASS libraries automatically resample input maps to the
current region.

The modules which perform other types of resampling (r.resamp.interp,
r.resamp.stats, r.resamp.rst) set the current region resolution and
alignment to match the input map, making the nearest-neighbour
resampling step a no-op.

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


More information about the grass-user mailing list