The way I've cobbled CATs onto buffered lines is given below.
I have two questions:
- Is there a better way to do this?
- What is the appropriate tool to use for v.clean after I have patched
everything together? The tool svtlx (listed in the man page for
v.patch) does not exist in v.clean.
I'm not that concerned about the intersections between the buffered
lines - they could be assigned to the CAT for any of the original
lines.
declare -i MYCOUNTER
MYCOUNTER=1
for MYCAT in 13 3 12 2;
do
v.extract input=seismicselect output=seismicselecttemp \
list=$MYCAT new=-1
## buffer it.
v.buffer input=seismicselecttemp output=seistempbuf type=line buffer=3
v.category input=seistempbuf output=seistempbuf2 type=centroid \
option=add field=2 step=1
v.category input=seistempbuf2 output=seistempbuf3 type=centroid \
option=sum field=2 cat=-1
v.category input=seistempbuf3 output=seistempbuf1 type=centroid \
option=sum field=2 cat=$MYCAT
if test "$MYCOUNTER" -eq 1; then
let "MYCOUNTER=$MYCOUNTER+1"
v.patch input=seistempbuf1 output=seisfintemp
else
v.patch input=seistempbuf1,seisfintemp output=seisfintemp2
g.remove vect=seisfintemp
g.copy vect=seisfintemp2,seisfintemp
fi
done
v.category input=seisfintemp option=report
Do you want again a buffer with cats from original lines?
Note that then 'overlapping' buffer areas may have more cats.
I would use something like this:
v.in.ascii -e output=seisbuf
for MYCAT in 13 3 12 2;
do
v.extract input=seismicselect output=seismicselecttemp \
list=$MYCAT new=-1
v.buffer input=seismicselecttemp output=seistempbuf \
type=line buffer=3 # the buffer has cat=1
let "ADD=$MYCAT-1"
v.category input=seistempbuf output=seistempbuf2 type=centroid \
option=sum cat=$ADD # the buffer has cat=$MYCAT
v.overlay -t ainput=seisbuf binput=seistempbuf2 output=seistempbuf3 \
ofield=0,1,1 # input cats are written to output with field=1
g.copy -o vect=seistempbuf3,seisbuf
done
Radim
On Tuesday 17 August 2004 01:22, Craig Aumann wrote:
The way I've cobbled CATs onto buffered lines is given below.
I have two questions:
- Is there a better way to do this?
- What is the appropriate tool to use for v.clean after I have patched
everything together? The tool svtlx (listed in the man page for
v.patch) does not exist in v.clean.
I'm not that concerned about the intersections between the buffered
lines - they could be assigned to the CAT for any of the original
lines.
declare -i MYCOUNTER
MYCOUNTER=1
for MYCAT in 13 3 12 2;
do
v.extract input=seismicselect output=seismicselecttemp \
list=$MYCAT new=-1
## buffer it.
v.buffer input=seismicselecttemp output=seistempbuf type=line buffer=3
v.category input=seistempbuf output=seistempbuf2 type=centroid \
option=add field=2 step=1
v.category input=seistempbuf2 output=seistempbuf3 type=centroid \
option=sum field=2 cat=-1
v.category input=seistempbuf3 output=seistempbuf1 type=centroid \
option=sum field=2 cat=$MYCAT
if test "$MYCOUNTER" -eq 1; then
let "MYCOUNTER=$MYCOUNTER+1"
v.patch input=seistempbuf1 output=seisfintemp
else
v.patch input=seistempbuf1,seisfintemp output=seisfintemp2
g.remove vect=seisfintemp
g.copy vect=seisfintemp2,seisfintemp
fi
done
v.category input=seisfintemp option=report
Thanks! That's certainly a bit cleaner.
I don't understand your v.overlay command, however. My version of
Grass5.7 doesn't have an ofield option. Similarly, I don't see why
field=1 should send things to the output - the only options I see are
afield and bfield.
A bit confused by what you mean!
Craig
v.overlay -t ainput=seisbuf binput=seistempbuf2 output=seistempbuf3 \
ofield=0,1,1 # input cats are written to output with field=1
New option. v.overlay writes 3 categories, first is a new unique
cat, the second is that from ainput and the third from binput;
fields are in this order. 'ofield' can change output fields.
With 'ofield=0,1,1' it will not write new unique cat
and it will merge cats from ainput and binput
into field 1 (i.e. two cats of the same field).
This option was added exactly for what you are doing - patching
of overlapping areas.
Radim
On Tuesday 17 August 2004 17:57, Craig Aumann wrote:
Thanks! That's certainly a bit cleaner.
I don't understand your v.overlay command, however. My version of
Grass5.7 doesn't have an ofield option. Similarly, I don't see why
field=1 should send things to the output - the only options I see are
afield and bfield.
A bit confused by what you mean!
Craig
> v.overlay -t ainput=seisbuf binput=seistempbuf2 output=seistempbuf3 \
> ofield=0,1,1 # input cats are written to output with
> field=1
How new? I'm running on Red Hat Enterprise 3.0.
[root@landscape installs]# rpm -q grass
grass-5.7.0-1
I've just looked at the online binaries, and I think I have the most
recent RPM installed.
Am I going to have to compile from source?
Cheers!
Craig
On Tue, 2004-08-17 at 10:38, Radim Blazek wrote:
New option. v.overlay writes 3 categories, first is a new unique
cat, the second is that from ainput and the third from binput;
fields are in this order. 'ofield' can change output fields.
With 'ofield=0,1,1' it will not write new unique cat
and it will merge cats from ainput and binput
into field 1 (i.e. two cats of the same field).
This option was added exactly for what you are doing - patching
of overlapping areas.
Radim
On Tuesday 17 August 2004 17:57, Craig Aumann wrote:
> Thanks! That's certainly a bit cleaner.
>
> I don't understand your v.overlay command, however. My version of
> Grass5.7 doesn't have an ofield option. Similarly, I don't see why
> field=1 should send things to the output - the only options I see are
> afield and bfield.
>
> A bit confused by what you mean!
> Craig
>
> > v.overlay -t ainput=seisbuf binput=seistempbuf2 output=seistempbuf3 \
> > ofield=0,1,1 # input cats are written to output with
> > field=1
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"