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

Moritz Lennert mlennert at club.worldonline.be
Tue Jun 4 04:59:29 PDT 2013


On 04/06/13 13:49, Nikos Alexandris wrote:
> 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.

How about a select that gets you all the cat values of the features your 
interested in, then v.extract with list= (or put the cat values into a 
file and use the file= parameter) ?

Moritz



More information about the grass-user mailing list