[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 08:46:21 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.
> > > ....
> > > Question: IS there a way to add these labels to the raster map
> > > non-interactively?
> > 
Hamish:
> > 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)
N:
> > > *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
[...]
H:
> > it is very close, just `tr '|' ':'` or `sed -e 's/|/:/'`.
> > Hopefully ":" in the label names won't cause a problem.
> 
> The result from both is the same:
> r.category map=glc2000_eu rules=`db.select -c glc2000_legend | tr '|'
> ':'`
> or
> r.category map=glc2000_eu rules=`db.select -c glc2000_legend | sed -e
> 's/|/:/'`
> 
> output:
> Sorry <Cover,> is not a valid option
> Sorry <broadleaved,> is not a valid option
> Sorry <evergreen> is not a valid option
> Sorry <2:Tree> is not a valid option
[...]
> 
> Finally it worked like this:
> 
> 1. db.select -c glc2000_legend | tr '|' ':' > glc2000_legend.csv
> 
> 2. r.category map=glc2000_eu rules=glc2000_legend.csv

Right, it wants a filename or "-" for the rules= option:
   rules   File containing category label rules (or "-" to read from
stdin)

it was thinking your DB dump was a very large filename....


using stdin you could have done like:
  db.select -c glc2000_legend fs=: | r.category map=glc2000_eu rules=-


> > ("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, ...
> 
> Why not directly from the db.table(s)
>
> Given that the category numbers and labels are there as they should be
> (in a table imported in the data base), wouldn't it be nice to enable
> attachment of such tables in a raster map?

see
 http://grass.gdf-hannover.de/wiki/GRASS_SoC_Ideas_2008#Raster_Database


> Cheers and THANKS!!!

no worries, this new r.cats label management option isn't well tested
yet, I'm glad someone is trying it out. In the past you had to use
r.support or hack the file by hand.


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