[GRASS-user] SOLVED: How to implement 2D lookup table?

Glynn Clements glynn at gclements.plus.com
Thu May 23 16:37:20 PDT 2013


Rainer M. Krug wrote:

> >> Hmm - sounds interesting, but also for other purposes. But as the result
> >> will be a raster map, I don't think this approach is usable here (unless
> >> I can feed the numbers back into a raster map, i.e. the inverse of
> >> r.stats -c)
> >
> > r.cross + r.reclass ?
> 
> There is one aspect in r.cross which makes this approach quite
> difficult to implement: the value of the result map layer can not easily
> be traced back to the values of the two input layers:

If you only have a small number of classes, you can just create the
cross-product manually, e.g.:

	r.mapcalc 'result = ageClass * 10 + dc'

So a category of 15 would be ageClass=1, dc=5.

r.cross is more useful when the total number of pairs which actually
occur is much fewer than the product of the numbers of categories, as
it only creates a category for each combination which actually occurs,
not for each potential combination.

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


More information about the grass-user mailing list