1

Many topics are talking about merging polygons based on their common attributes, but few (or none) give a real answer to location-based merging problem.

Explanation.

Here is a fraction of the base map:enter image description here

Some polygons are adjacents but belong to different entities. I want them to merge when they touch and stay as they are if they don't. Then, I want to extract the area of the new entities out of it.

Due to the large size of the maps, I'm working on Grass.

To solve the problem, I first made a tiny buffer:

grass_util.g('v.buffer', input='map', output='map_buffer', type=area distance=0.001)

My output is this one:

enter image description here

Everything looks pretty good, except that making a buffer brings the entities to merge into the one same entity (as displayed by the attr table that I can display here due to my small reputation). More precisely, the number of entities is almost the same, a bit less, the ones that didn't merge plus the new merged ones, but they are all affected "1" in the only category: "cat".

So we still have our different polygons, different entities, but they are merged.

Following this, when I try to add a new column and fill it with geometrics (my area in ha):

grass_util.g('v.db.addcolumn' map='map_buffer' col="area int") grass_util.g('v.to.db', map='map_buffer', option=area, column=area, unit=h)

It lamely fails ! The area isn't calculated for each entity and attributed to it. It is calculated for the whole package, and every entity gets the area of the whole.

I have to say that I don't really see how to get this thing sorted. I tried dissolve, v.clean, v.build, multiple to one and one to multiple, I tried to deconstruct the polygones to lines and to reconstruct them again.

An option which need the processing module that I don't have yet is to use this command:

processing.runalg('qgis:exportaddgeometrycolumns', input, calc_method, output)

which works when I try on a small area in Qgis Gui.

The question is twofold:

  1. Find an other way to merge the adjacent polygons based on their location (to avoid the destructive buffer)
  2. Find a way to get back my entities and retrieve their personal areas.
  • Sounds like you want the Grass equivalent to ArcGIS Dissolve. You can dissolve without having common attributes. help.arcgis.com/EN/ARCGISDESKTOP/10.0/HELP/index.html#//… – BERA May 24 '16 at 11:04
  • I think you should focus this question of your first question, and then think about asking a new question for the second question, if this one fails to solve it along the way. – PolyGeo May 24 '16 at 11:15
  • @Björn Thanks but I don't have ArcGis, I'm working on Qgis. PolyGeo Alright ;) – EGyo May 24 '16 at 12:09
1

What you need to do is add a single category value to all polygons in a second layer, then run v.dissolve using that layer 2. This will remove all common boundaries. Here are the steps (say your original is named "polys"):

v.category polys opt=add layer=2 out=polys2 cat=1 step=0
v.dissolve input=polys2 layer=2 out=polys3
v.db.addtable polys3 column="area_sqm double precision"
v.to.db polys3 option=area units=meters column=area_sqm

The parameters "cat=1 step=0" insure that all categories in layer 2 are=1. Then v.dissolve works on all common boundaries.

  • 1
    Hi, Thanks for you reply but it doesn't work. Here's the end of the log: v.db.addtable polys3 column=area_sqm double precision --overwrite DB settings already defined, nothing to do Reading features... Updating database... 0 categories read from vector map (layer 1) 0 records updated/inserted (layer 1) – EGyo May 25 '16 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.