[GRASS-user] multiple polygons with same cat
markus.metz.giswork at gmail.com
Tue Nov 26 01:25:38 PST 2013
On Tue, Nov 26, 2013 at 3:39 AM, Dave Roberts
<dvrbts at ecology.msu.montana.edu> wrote:
> I'm not exactly a newbie, but still yet quite naive in GRASS. This seems
> like a simple problem, but I suspect unforeseen problems with the simple
> I have imported a surficial geology map from a shapefile. There are 1082
> polygons. Each of the polygons with the same surficial geology (e.g Agn,
> Archean gneiss) has the same cat (i.e. there are 29 polygons with cat=3). I
> would like to add several columns to this table (e.g. geologic era and
> primary lithology (e.g. granite vs limestone)).
> I normally associate all vector maps with a table in PostgreSQL using cat
> as the primary key (i.e. v.db.connect -o key=cat), but that clearly won't
> work here. I could rename the column 'cat' in the DBF file, and add a new
> column with values 1-1082 as cat.
That does not work because the geometries don't get new categories.
> If I save that as a new DBF file in a new
> shapefile directory, when I re-import with v.in.ogr will it necessarily get
> it right? I.e, will GRASS associate the vertices the first polygon in the
> shapefile with the first row in the DBF file? I only ask because PostgreSQl
> (like most DBMSs) does not guarantee the records to be in any specific
> order, and perhaps shapefiles don't either?
Shapefiles (using DBF) require the records in a specific order. GRASS
vectors do not require records to be in a specific order, they link
geometries to the appropriate record with the key column.
> Is there a simple way to renumber the polygons 1 through 1082 that
> maintains integrity and allows me to connect the vector coverage to
> PostgreSQL instead of DBF?
v.category map=geo type=centroid op=add layer=2
That will create a new layer where each area has a unique category.
The original layer where several areas share the same category is
preserved. You can add a new table to this layer with v.db.addtable
layer=2. Then you can transfer attributes from one layer to another
More information about the grass-user