On Tue, Nov 26, 2013 at 2:43 PM, Dave Roberts <[email protected]> wrote: > Thanks Markus. This has me on the right track, but I haven't gotten it all > to work yet. > > > v.category map=geo type=centroid op=add layer=2 > > refused to work without a new output map, so
ah, right. > > v.category inp=geo out=new_geo op=add layer=2 you need to add the option type=centroid, see above, otherwise the results might be unexpected. > > produced a new vector map where the cats are unique for each polygon. > > doing d.what.vect new_geo shows the old data in layer 1 and the new data in > layer 2 > > Curiously, there are now 3938 polygons (instead of 1082). That can be a side-effect of not using type=centroid with v.category. Additionally, boundaries have now also categories, leading to a much larger attribute table. I would suggest to run v.category inp=geo type=centroid out=new_geo op=add layer=2 --o followed by v.category inp=geo op=report to see what happened. HTH, Markus M > If I do a > v.db.connect to a table in Postgres and then v.to.db move over the cat and > coor data psql shows that the first 2725 records are null (except for cat) > and the X,Y coordinates start at cat 2726, giving me 1212 polygons with real > data. > > I could maybe delete the first 2726 records and join this new table to > the one with the stratigraphy data on the X and Y coordinates, but doing > exact equality on floating point numbers is madness. > > Any ideas? > > Thanks, Dave > > > On 11/26/2013 02:25 AM, Markus Metz wrote: >> >> On Tue, Nov 26, 2013 at 3:39 AM, Dave Roberts >> <[email protected]> wrote: >>> >>> Friends, >>> >>> 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 >>> solution. >>> >>> 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 >> with v.to.db. >> >> HTH, >> >> Markus M >> > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > David W. Roberts office 406-994-4548 > Professor and Head FAX 406-994-3190 > Department of Ecology email [email protected] > Montana State University > Bozeman, MT 59717-3460 _______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
