1

I am working on a project for determining potential areas. Therefore I am extracting many features e.g. roads, waterways, nature reserves which need to be buffered with a specific distance. All these features will be subtracted from another layer.

In the following, I will be using the example feature roads for showing my problem:

  1. Extracted roads are linestrings.
  2. Linestrings get buffered.
  3. Due to buffering, the resulting layer has many intersections.

Roads as linestrings and buffered linestrings

I tried using the union function to dissolve all intersections. Due to the size of the data set, unioning takes hours if not days - and even crashes the server.

So I tried to not use union by directly subtracting the buffered roads from the final layer. Without any conditions on the query, the difference algorithm also takes way to long due to many polygons in the road table.

Final layer and buffered roads that need to be subtracted

Then I tried to use the st_intersects method for speeding up the calculation (query can be found below). I also created a spatial index on all the tables. This indeed calculates a lot faster but the final difference does not make any sense. (See attached picture)

Instead of calculating a difference, only some features are considered. I also tried the fix geometry function (st_makevalid) with no other results.

CREATE TABLE schema.difference_result AS
SELECT st_difference(table1.geom, roads.way_buffer)
FROM schema.table1, schema.roads
WHERE st_intersects(table1.geom, roads.way_buffer);

Wrong difference layer

My project contains very big data sets from all over Europe. Therefore it might be an idea to use grid processing but I have no idea how to implement it. I am not an SQL expert.

2
  • Thanks for the quick answer. Clustering may not be the right algorithm as almost all of the buffered polygons overlap as they originate from an almost fully connected network of linestrings. Even if I use clustering to union those cluster there would still be intersections among the clusters (if there are any). Commented Oct 15, 2021 at 13:06
  • see this post for keeping overlapping sections in one of the layers only.
    – JGH
    Commented Oct 15, 2021 at 14:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.