[GRASS-user] v.patch and v.clean: how to preserve atribute table

Paolo Craveri pcraveri at gmail.com
Wed Apr 1 16:33:22 EDT 2009


Hi Jarek

2009/3/31 Jarek Jasiewicz <jarekj at amu.edu.pl>:
> problem seems to be very simple;
[...]
> Any suggestion how to join these bundle of polygons into one vector and
> preserve its attributies?

I have tried this:

#!/bin/bash
# # spearfish60
db.connect database='$GISDBASE/$LOCATION_NAME/$MAPSET/mydbsqlite' driver=sqlite
g.copy vect=soils,mysoils --overwrite
# # # create a lot of vectors (polygons) to use as example
for i in $(v.db.select soils col=cat -c); do
	v.extract in=mysoils out="pippo${i}" where="cat=${i}" --overwrite
done

# # try with v.out.ogr, ogr2ogr, v.in.ogr
for vect in $(g.mlist type=vect pattern="pippo*"); do
	v.out.ogr in=${vect} dsn=./shptmp/ olayer=${vect} type=area
format=ESRI_Shapefile
done

# # non topological merge
index=1
for shpfile in ./shptmp/*.shp; do
        if [ $index = 1 ]; then
                ogr2ogr "./shptmp/merge.shp" ${shpfile}
        else
                ogr2ogr -update -append "./shptmp/merge.shp"
${shpfile} -nln "merge"
        fi
       index=$(($index+1))
done
v.in.ogr dsn=./shptmp/ layer=merge out=merge_bad --overwrite
v.clean in=merge_bad out=merge tool=bpol,rmdupl --overwrite
v.db.select merge
v.info -t mysoils
v.info -t merge_bad
v.info -t merge

but I am not so sure about  the final result...

Can anyone tells me if above procedure is correct ? Many thanks in advance.

ciao

-- 
-- 
Paolo C.
Lat. 44° 39' 11.08'' N  Long. 7° 23' 25.26'' E


More information about the grass-user mailing list