[GRASS-user] v.to.rast shell script

Hamish hamish_b at yahoo.com
Sat Sep 20 02:49:37 EDT 2008


John Tull  wrote:
> >> I was wondering if anyone could suggest a simple shell script to
> >> automate the process of running v.to.rast on all layers in
> >> a single vector in GRASS?
HB:
> > sure, just a bash for loop + g.mlist will do it:
> >
> > for MAP in `g.mlist vect` ; do
> >   echo v.to.rast in="$MAP" out="`echo $MAP | tr '[:lower:]'  
> > '[:upper:]'`"
> > done
JH:
> Thank you for your quick response. This, with the addition of  
> 'type=vect' will give me a list of vectors, but I was wanting a list  
> of layers within a single vector. I am guessing there might be a way  
> to cajole v.info into doing this, but am not sure how at this point.

ah, sorry. reading too quickly.


for LAYER in `v.info -c fields --quiet | cut -f2 -d'|'` ; do
  echo "Layer is [$LAYER]"
done

(cut takes the second field and uses | as the field separator)


Instead of 'v.info -c' you could use db.columns or 'db.describe -c'.
Those two will only work if the map (ie DB) is in the current mapset.


add " | grep -v CHARACTER" or " | grep 'INT\|DOUBLE'" if you wish to
skip text columns.


Hamish


      



More information about the grass-user mailing list