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

Rainer M Krug Rainer at krugs.de
Thu May 23 01:26:15 PDT 2013


Hi

I have two raster layers

,----
| dc: CELL, 1, ..., 7, NULL
| ageClass: CELL, 1,2,3,NULL
`----

And I want to create a third one, depending on the value in a lookup table. dc corresponds to the row, ageClass to the column,

The lookup table looks as follow:

,----
|     seedling young adult
| dc1   425000 87500 37500
| dc2   270000 55000 23500
| dc3   127500 26000 11250
| dc4    32500  7100  3200
| dc5     5550  1220   500
| dc6      605   132    55
| dc7       56    12     6
`----

Now I want to have something like (using r.mapcalc as an example)

,----
| r.mapcalc expression = "result = lookupTable[col=ageClass, row=dc]"
`----

and e.g. for one cell

,----
| ageClass = 3
| dc = 5
| ==> 
| result = 500
`----

I haven't found anything like this in GRASS.

I could use MASKS and then r.reclass(), or generate dynamically a
complex if() construct, but both options sound a little bit
awkward to me.

I am scripting GRASS from R, so there is always the option of doing it
in R, but there is the issue of reading the data into R and writing it
back to GRASS, which takes time. As I am doing this in a simulation
which runs several times, this is not an unimportant issue.

Is there better way of achieving this?

Thanks,

Rainer

-- 
Rainer M. Krug

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer at krugs.de

Skype:      RMkrug
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20130523/8142238a/attachment.pgp>


More information about the grass-user mailing list