4

We have many adjacent polygons which are very complex and we need to simplify only some portions of them.

There are no gaps nor overlaps between any two adjacent polygons.

What we'd like to do is to select a subset of the vertices delimiting two adjacent polygons together, and then simplify only this subset, while maintaining no gaps or overlaps between two adjacent resulting polygons:

example

Is it possible to achieve that in QGIS for instance (or any other tool)?

We've looked into some options to simplify adjacent polygons, but can't find a way to do that on only a subset of the polygons.

  • 2
    An interesting question. – Kadir Şahbaz Jun 9 at 12:07
  • 2
    Do you want to use just QGIS or could you imagine to try some other open source GIS software? – user30184 Jun 9 at 13:21
  • @user30184 plaftorm agnostic – Jivan Jun 9 at 13:39
  • 1
    Did you check the topojson format? You can convert your data to topojson using the geo2topo from the topojson-server node app. Then, using a json parser (inside python, R, ir your favorite languaje), identify the arcs shared by your target polygons and simplify them, keeping only the nodes you want. See github.com/topojson/topojson-server and github.com/topojson/topojson-specification – Javier JC Jun 11 at 4:21
2

I hope that I understood your question correctly.

Let's assume there one layer "polygons" with its corresponding attribute table accordingly, see image below.

input

And of course there are some gaps or overlaps.

gaps_and_overlaps

Below I am suggesting a step-by-step process of how to simplify only the subset of polygons, while maintaining no gaps or overlaps between two adjacent resulting polygons.

Step 1. Divide your original layer into "good" and "bad" features. I used 'Extract by expression', e.g. "id" IN (2,3) and "id" NOT IN (2,3). However, you can use any other available technique to separate your features.

step_1

Step 2. Converting polygons into lines with 'Polygons to lines'.

step_2

Step 3. Applying 'Line intersections' where lines intersect themself. In addition exploit 'Delete duplicate geometries'.

step_3

Step 4. Proceed further with 'Points to path'.

step_4

Step 5. Apply 'Dissolve' to your "bad" features.

step_5

Step 6. Use 'Delete holes'

step_6

Step 7. Here work with 'Split with lines' between the result of Step 6 and Step 4.

step_7

Step 8. Because of the inconsistent attributes evoked on the previous steps some extra paces on how to achieve correct attributes are required. I will probably extract geocentroids from the result of the Step 7, then apply 'Join attributes by location' and afterwards a basic 'Join' between polygons with correct geometries and points with correct attributes.

Step 9. Merging "good" features with the result of Step 8 via 'Merge vector layers'. And of course some basic attributes adjustment is a plus.

step_9


If you need straight lines for the step Step 4. then there are a couple of more steps have to be applied.

Step 4.1. Dissolve your paths with 'Dissolve'.

Step 4.2. Attaining a straight line by means of a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... apply this query

SELECT setsrid(make_line(start_point(geometry), end_point(geometry)), #put your srid here)
FROM "Paths"

step_42

There are might be better options with lines simplification algorithms, did not check that yet.


P.S. IMHO this algorithm is better to implement in a Graphical Modeler.


References:

| improve this answer | |
1

The job can be done with OpenJUMP but the method is generic and any software can be used. What matters is that the software must be able to create a planar graph and build polygons from closed areas between linestrings.

Start with topologically clean data where adjacent polygons have exactly matching common borders.

source polygons

Create planar graph. You need only the edges.

planar graph in OpenJUMP

options for planar graph

From the planar graph select the lines that you want to simplify.

Planar graph with one selected edge

options for D-P simplification

When you are satisfied with the simplification build polygons from the graph.

build polygons with OpenJUMP

new polygons with one simplified border

As a final step you must copy the attributes from the source layer into new polygons with spatial join.

Unfortunately real World polygon datasets usually have poor topology. Common borders do not match but there are small gaps and overlaps. It may be faster to digitize a few borders manually than to fix the source data so that it can be converted into lines and back to polygons without errors.

| improve this answer | |
1

Clarification - if you do not have an "id" field in your table, create it and use it to identify the right and left (upper and lower) adjacent polygons.

  1. One of the ways to solve this problem is as follows. My initial situation is depicted in the figure below:

enter image description here

  1. Run the script (CTE), which I think is appropriate for your case of geodata processing, setting your table name and field name, for example "id"
WITH tbla as (SELECT id, ((ST_Dump(geom)).geom) geom
              FROM <table_name>
              ),
              
tblb as (SELECT a.id, ((ST_Dump(ST_Difference(ST_ExteriorRing(a.geom), ST_ExteriorRing(b.geom)))).geom) geom 
         FROM tbla a
         LEFT JOIN tbla b ON ST_Intersects(a.geom, b.geom) AND a.id < b.id
         ),
         
tblc as (SELECT id, ST_MakePolygon(ST_AddPoint(geom, ST_StartPoint(geom))) geom
         FROM tblb
         ),
         
tbld as (SELECT a.id, ((ST_Dump(ST_Difference(ST_ExteriorRing(a.geom), ST_ExteriorRing(b.geom)))).geom) geom 
         FROM tbla a
         LEFT JOIN tbla b ON ST_Intersects(a.geom, b.geom) AND a.id > b.id
         ),
         
tble as (SELECT id, ST_MakePolygon(ST_AddPoint(geom, ST_StartPoint(geom))) geom
         FROM tbld
        )
         
SELECT *
FROM tblc
UNION
SELECT *
FROM tble;
  1. Check your result, my result is shown in the figure below

enter image description here

Translated with www.DeepL.com/Translator (free version)

| improve this answer | |

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.