[GRASS-user] RE : RE : Merge polygone with same attribut of a shapefile
Nikos Alexandris
nik at nikosalexandris.net
Fri May 17 01:29:20 PDT 2013
Nikos Alexandris a écrit :
> > Funny, I am "stuck" as on how to (re-)define in layer 2 the "cat"
> > column with
> > unique categories for each (internal) feature id. There is nothing
> > that
> > helps-out towards this (simple?) task in the manuals (v.to.db).
Vincent Bain wrote:
> this should do the job:
> v.category op=add layer=2 type=centroid
> then
> v.to.db type=centroid option=cat
Thank you Vincent. I think I've tried exactly that but it fails. It'll work
only by creating a *new* vector map... Otherwise, it wont work (at least from
what I've tried in G7).
So, the process could be (given the shapefile provided by Lucien ):
# import shapefil
v.in.ogr dsn=test_polygones.shp out=polygons
# create a new layer 2
v.db.addtable polygons layer=2
# check...
v.db.connect polygons -p
v.db.select polygons
v.db.select polygons layer=2
# add unique cats -- this will not work if "out=" is not defined!
v.category polygons option=add layer=2 type=centroid out=polygons_tmp
v.to.db polygons_tmp type=centroid option=cat layer=2 col=cat
# get stats for cats-wide stats for layer 1, that is only one cat!
v.rast.stats -c vector=polygons_tmp raster=RandomRaster column_prefix=rr
# get stats for cats in layer 2, that is for all different cats!
v.rast.stats -c vector=polygons_tmp raster=RandomRaster column_prefix=rr2
layer=2
#...unfortunately, this last step in uploading stats in to layer 2, fails in
G7 :-(
# it works in G64! -- note different parameter naming: "colprefix="
v.build polygons_tmp
v.rast.stats -c vector=polygons_tmp layer=2 raster=RandomRaster colprefix=rr2
Regards, Nikos
More information about the grass-user
mailing list