[GRASS-user] v.extract features based on multiple SQL statements in one go

Nikos Alexandris nik at nikosalexandris.net
Tue Jun 4 04:49:45 PDT 2013


Hi list!

Can I avoid the "for loop + v.patch" below

	for PATHROW in `cat wrspr_of_interest`; do v.extract --o in=wrs2_descending 
type=area where="WRSPR = ${PATHROW}" output=wrs2_of_interest_${PATHROW}; done

	v.patch in=g.mlist vect pat=wrs2*_?????? out=wrs2_tiles_of_interest

and do all the magic in one step instead? As in feeding multiple SQL 
statements/lines in db.execute?  v.extract does not seem to support this 
(maybe too complicated).


Is the only alternative to construct a single-long SQL statement? Using, e.g.

# what is requested?
cat /geo/geodata/mangroves/geolocations/sources/ascii/wrspr_of_interest2

SELECT * FROM wrs2_descending WHERE WRSPR = 160043 or WRSPR = 161043 or WRSPR 
= 193056

# select it
cat /geo/geodata/mangroves/geolocations/sources/ascii/wrspr_of_interest2 | 
db.select input=-

cat|AREA|PERIMETER|PR_|PR_ID|RINGS_OK|RINGS_NOK|WRSPR|PR|PATH|ROW|MODE|
DAYCLASS|SEQUENCE
12071|2.82726|6.76119|2523|2523|1|0|160043|160043|160|43|D|7|22611
24719|2.82726|6.76119|2523|2523|1|0|161043|161043|161|43|D|14|47907
24980|2.59335|6.45272|3032|3032|1|0|193056|193056|193|56|D|14|48416


Even so, I can't feed this to "v.extract" directly.

(
Sidenote:  I am trying to trace a, maybe similar, action of mine some years 
ago, where Hamish pointed how inefficient my script-ing was, opening/executing 
SQL/closing multiple times a file.  Can't locate it though.
)

Thanks, Nikos


More information about the grass-user mailing list