[GRASS-user] Can a table imported in the data base (sqlite.db) used to assign new raster category labels non-interactively?

Hamish hamish_b at yahoo.com
Tue Mar 18 01:42:52 EDT 2008


Nikos Alexandris wrote:
> I am having a hard time to figure out how I could avoid to enter
> interactively new labels for a raster map. I've been reading the last 2
> hours in the list, in GRASS-Book.
> 
> Any directions highly appreciated.
....
> Question: IS there a way to add these labels to the raster map
> non-interactively?


In GRASS 6.3 use 'r.category rules=filename'. See the help page.
(new option added in October; may not have filtered into all the docs
yet)


In GRASS 6.2 you can put a similar ASCII text file in the $MAPSET/cats/
dir, see the Programmers' manual or another map to get the format.



> *Looking at the imported table
> db.select -c glc2000_legend
> 1|Tree Cover, broadleaved, evergreen
> 2|Tree Cover, broadleaved, deciduous, closed
> 3|Tree Cover, broadleaved, deciduous, open
> 4|Tree Cover, needle-leaved, evergreen
> 5|Tree Cover, needle-leaved, deciduous
> 6|Tree Cover, mixed leaf type
> 7|Tree Cover, regularly flooded, fresh water
> 8|Tree Cover, regularly flooded, saline water
> 9|Mosaic: Tree Cover / Other natural vegetation
> 10|Tree Cover, burnt
> 11|Shrub Cover, closed-open, evergreen
> 12|Shrub Cover, closed-open, deciduous
> 13|Herbaceous Cover, closed-open
> 14|Sparse herbaceous or sparse shrub cover
> 15|Regularly flooded shrub and/or herbaceous cover
> 16|Cultivated and managed areas
> 17|Mosaic: Cropland / Tree Cover / Other natural vegetation
> 18|Mosaic: Cropland / Shrub and/or grass cover
> 19|Bare Areas
> 20|Water Bodies
> 21|Snow and Ice
> 22|Artificial surfaces and associated areas
> 23|Irrigated Agriculture


it is very close, just `tr '|' ':'` or `sed -e 's/|/:/'`.
Hopefully ":" in the label names won't cause a problem.

("TODO: Respect the fs= field separator setting for input rules.")


Also for GRASS 7 it would be nice to use a consistent fs for all modules,
instead of sometimes |,:,space, ...


Hamish



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping



More information about the grass-user mailing list