Dear grass mailing list readers,
I’m scripting a big project with vector data in grass using Python and the GRASS Python scripting library.
At some point I use ‘dissolve’ to remove a whole lot of boundaries.
In the resulting map not all centroids have identical cats. They represent areas with identical attributes, having one record with that data in the database. Effectively this gives me something like ‘multi-polygons’.
For the next step in my process, I need all centroids to have unique cats, with their own attributes-record in the database. I have to ‘split’ the ‘multi polygons’ (in geometry-terms) so to say.
Anyone a good suggestion how to handle this properly? With geometry I would be able to dump the individual areas from a multi-polygon.
There are areas in my map without a centroid, representing holes which have to stay a hole. Throwing away all centroids, creating new ones and doing a v.what on the original layer is a bit buggy at times (as some areas tend to be very slender and such).
Kind regards,
Martin
p.s. Some years ago, doing something similar, I did not have this problem, and dissolve returned a fresh cat for every area, with its attributes in the database table.
Martin Koch
Teamleider data
(attachments)
PastedGraphic-1.tiff (38.8 KB)
On 12/08/13 13:29, Martin Koch wrote:
Dear grass mailing list readers,
I'm scripting a big project with vector data in grass using Python and
the GRASS Python scripting library.
At some point I use 'dissolve' to remove a whole lot of boundaries.
In the resulting map not all centroids have identical cats.
I imagine this is supposed to say: "not all centroids have unique cats" ?
They
represent areas with identical attributes, having one record with that
data in the database. Effectively this gives me something like
'multi-polygons'.
For the next step in my process, I need all centroids to have unique
cats, with their own attributes-record in the database. I have to
'split' the 'multi polygons' (in geometry-terms) so to say.
You try with v.category layer=2 op=add to create new unique cat values for you centroids in layer 2, v.db.addtable to create and attribute table for layer 2 and then v.to.db [...] layer=2 op=query qlayer=1 qcolumn=cat to get the original cat values into the new attribute table.
p.s. Some years ago, doing something similar, I did not have this
problem, and dissolve returned a fresh cat for every area, with its
attributes in the database table.
Could you give the exact commands and version of GRASS you use ?
Moritz
Op 28 aug. 2013, om 14:41 heeft Moritz Lennert <mlennert@club.worldonline.be>
het volgende geschreven:
On 12/08/13 13:29, Martin Koch wrote:
In the resulting map not all centroids have identical cats.
I imagine this is supposed to say: "not all centroids have unique cats" ?
Stand corrected….
For the next step in my process, I need all centroids to have unique
cats, with their own attributes-record in the database. I have to
'split' the 'multi polygons' (in geometry-terms) so to say.
You try with v.category layer=2 op=add to create new unique cat values for you centroids in layer 2, v.db.addtable to create and attribute table for layer 2 and then v.to.db [...] layer=2 op=query qlayer=1 qcolumn=cat to get the original cat values into the new attribute table.
Thanks Moritz … will implement this elegant solution in the next version of my control script. I rarely need more than one layer in my maps, so using that possibility did not come to my mind when I needed it. I now do basically the same with some temporary tables in between.
p.s. Some years ago, doing something similar, I did not have this
problem…….
Could you give the exact commands and version of GRASS you use ?
I have to apologize on this. I was a bit over reacting. Only remembered that at a certain stage in my old process I had unique cat's. Looking closer at the years old script in my repo reveals I send those maps to and from PostGIS for some other reason. Thus magically reappearing with unique cat's.
Kind regards,
Martin