[GRASSLIST:4200] Re: Adding CATS to buffered lines (Grass5.7)

Craig Aumann caumann at ualberta.ca
Tue Aug 17 18:12:50 EDT 2004


If anyone is interested, below is the code for cobbling attribute values
onto the output of v.buffer for lines using the new ofield=x,x,x of
v.overlay.   To avoid areas with more than a single CAT, I had to do a
bunch of v.overlay's followed by a v.extract -d  

Cheers!
Craig




### The CAT in field 2 is  equal to the link_key.  

declare -i MYCOUNTER
MYCOUNTER=1
v.in.ascii -e output=seisbuf
for MYCAT in `echo "select distinct link_key from
seismicselect_att"|db.select -c`;  do 
    v.extract input=seismicselect output=seismicselecttemp \
	field=2 new=-1 list=$MYCAT
    
## buffer it. 
    v.buffer input=seismicselecttemp output=seistempbuf \
	type=line buffer=3
    
    let "ADD=$MYCAT-1"
    
    v.category input=seistempbuf output=seistempbuf2  \
	option=sum cat=$ADD 
  
  
    if test "$MYCOUNTER" -eq 1; then      
	let "MYCOUNTER=$MYCOUNTER+1"    
	v.overlay -t ainput=seisbuf binput=seistempbuf2 output=seistempbuf3 \
	    ofield=0,1,1  
	
      ## Above ofield=0,1,1 will merge the cats from ainput & binput 
      ## into field 1 of the output
	
	g.copy -o vect=seistempbuf3,seisbuf
	
    else
	v.overlay -t ainput=seisbuf binput=seistempbuf2 output=seistempbuf3  \
	    operator=and
	
      ## field 3 has the CAT  we want.  Now merge this in.  
      ## Specify ofield so that only 1 CAT is merged in. 
      ## This is an arbitrary choice, but sufficient for my purposes  
	
	v.overlay -t ainput=seisbuf afield=1 binput=seistempbuf3 bfield=3 \
	    output=seistempbuf3a  ofield=0,1,0  
	
	g.copy -o vect=seistempbuf3a,seisbuf
	
	v.overlay -t ainput=seistempbuf2 binput=seisbuf output=seistempbuf4  \
	    operator=not
	
      ## field 2 has the CAT we want. Now merge this in
	
	v.overlay -t ainput=seisbuf binput=seistempbuf4 bfield=2 \
	    output=seistempbuf5 ofield=0,1,1
	
	g.copy -o vect=seistempbuf5,seisbuf
    fi
done


v.category input=seisbuf option=report

## Drop the DB connection to seismicselect_att
v.db.connect  -d map=seismicselect field=2 \
	driver=pg database="dbname=alpac_netdown,user=caumann"


echo "select distinct link_key from seismicselect_att"|db.select -c >
distinctcat.out

## Remove the boundaries between common CAT values.  
v.extract -d input=seisbuf output=seisbuffinal new=-1 \
    file=distinctcat.out

## Connect to the final seismic layer
v.db.connect  map=seisbuffinal table=seismicselect_att \
    key=LINK_KEY field=1 \
    driver=pg database="dbname=alpac_netdown,user=caumann"







More information about the grass-user mailing list