2

I have a buffer layer which I generated from a polyline layer and then dissolved. I then rasterized the dissolved buffer layer, thinned it based on this link and generated a new (more approximate) polyline layer which occurs at more or less the centerline of the dissolved buffer layer.

I also have a background raster containing values which I am interested in averaging later on. In summary my session looks something like this:

enter image description here

I would like to now find a way to segment that buffer layer based on a particular distance. This is the reason I thought that having a centerline polyline layer would be beneficial. In MS paint I have drawn an example of what I am aiming for:

enter image description here

I'd like to make the segments as perpendicular as possible to the edges of the buffer zone. I realize there is also the problem of how the segments are calculated when the road branches off as shown below. To this I would apply the algorithm employed by v.split.length, if possible.

How do I segment the buffer layer based on a regular centerline length of the dissolved polyline layer?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
user32882
  • 3,514
  • 2
  • 31
  • 67
  • it seems like the whole buffer-medial-axis thing you went through aims at a simplification of those initial lines? if so, I think you should rather explore common methods to do so. however, if you need this procedure, it would be easier to segmentize the lines and buffer the segments (check this, although I'm pretty sure the QGIS buffer tool has similar options). – geozelot Jul 25 '18 at 15:38
  • I might need to add that, with flat caps, there will possibly be gaps between segment buffers... – geozelot Jul 25 '18 at 15:45

3 Answers3

3

I'm not a programmer, and therefore I will tell you one of the options for solving your problem 1) The initial data line and set distance, see Figure 1

enter image description here

Split your source line into points in Figure 2

enter image description here

in any convenient way for you, or in the QGIS tool "Vector-processing geometry-extract nodes" or in PGAdmin.

2) Knowing the length of your line, create a point (points) of your interest, for example, create a temporary table with:

create table roadsegment_pt_split1 AS
SELECT ST_LineInterpolatePoint (roadsegments_marge.ggeom, 0.1) as geom
FROM roadsegments_marge

The result is shown in Figure 3 enter image description here

P.S. Wrap everything in a loop and get a set of necessary starting points (tables) on your line.

3) Create a temporary empty point table and copy the points that are before the "insertion point" into it, then copy and add the "insertion point" to the table at the end of the table, see Figure 4.

enter image description here

4) Create a table of type LineString from them

create table roadsegment_part1 as
SELECT ST_MakeLine (geom) as geom
FROM roadsegments_pt_split;

5) Finally you got the first segment, see Figure 5.

enter image description here

6) Now create the second segment, create a temporary bitmap, copy the "insertion point" into the beginning of the table! and add all points of your interest from the original dotted line (table) and create from them a second linear segment and so on, see Figure 6.

enter image description here

create table roadsegment_part2 as
SELECT ST_MakeLine (geom) as geom
FROM roadsegment_pt_split2;

In this way, you will create a set of line segments of interest to you.

7) Run the following code on your tables (line segments):

create table roadsegment_buffer_part1 as
SELECT ST_Buffer ((geom), 0.0001, 'endcap = flat join = round') as geom
FROM roadsegment_part1

You can also loop this process for all tables (line segments), as a result, you get what you expect, see Figure 7.

enter image description here

Programmers can, on the basis of this approach, write a miracle script :-) and all users will gladly use it to solve similar problems.

Cyril Mikhalchenko
  • 4,397
  • 7
  • 14
  • 45
  • well, it is indeed a good hint to consider moving things completely to PostgreSQL/PostGIS. you could have it even simpler than this procedure...,) – geozelot Jul 26 '18 at 11:22
  • Unfortunately, I am not ready to offer a simpler solution now, perhaps it will appear later as my knowledge grows and as a result of my ignorance growth :-), – Cyril Mikhalchenko Jul 26 '18 at 11:36
  • ThingumaBob, How do I add a "postgis" tag to this question, or move the "postgis" tag answers to postgis? – Cyril Mikhalchenko Jan 14 '19 at 19:11
  • just edit the question itself to add tags. but, tags are set to describe the questions implicit environment; there's no way to tag answers. ...I understand your intentions here, but there's no hint that OP uses PostGIS in this context...and I have the impression that tag would be wrong to set. – geozelot Jan 14 '19 at 19:43
1

Method 2 -

  1. Create lines of approximately equal length from lines, the line must be ordered!;
  2. Create buffer 2 with semicircular trimmed edges and along the required road width:
create table roads_union_byf as
SELECT id, ST_Buffer ((geom), 0.0001,'endcap=round join=round') as geom
FROM roads_split;
  1. Create boundary lines cut from one side (left):
create table roads_cut_l as
SELECT a.id, 
  ST_LineMerge(
    ST_Difference(ST_ExteriorRing(a.geom), b.geom)
  ) geom
FROM roads_union_byf a
LEFT JOIN roads_union_byf b ON (ST_Intersects(a.geom, b.geom) 
AND a.id < b.id);

  1. Create polygons from them:
create table roads_cut_poly_l as
SELECT id, ST_MakePolygon(ST_AddPoint(geom, ST_StartPoint(geom))) geom
FROM roads_cut_l;
  1. Create boundary lines cut from one side (right):
create table roads_cut_r as
    SELECT  a.id, 
      ST_LineMerge(
        ST_Difference(ST_ExteriorRing(a.geom), b.geom)
      ) geom
    FROM roads_union_byf a
    LEFT JOIN roads_union_byf b ON (ST_Intersects(a.geom, b.geom) 
    AND a.id > b.id);
  1. Create polygons from them:
create table roads_cut_poly_r as
SELECT id, ST_MakePolygon(ST_AddPoint(geom, ST_StartPoint(geom))) geom
FROM roads_cut_r;
  1. Connect the cut parts of the polygons into a common polygon:
create table roads_union_split as
SELECT ST_Intersection(a.geom, b.geom) as geom
FROM roads_cut_poly_r a, roads_cut_poly_l b
WHERE ST_Intersects (a.geom, b.geom)
AND a.id=b.id;

enter image description here

P.S. Thanks Tilt Clip overlapping polygon in equal sharing size, good luck

Cyril Mikhalchenko
  • 4,397
  • 7
  • 14
  • 45
0

@user32882,The idea of automating the solution of your problem is as follows:

1) Divide your lines into equal segments in any way convenient for you;

2) Create a buffer with rectangular sides from the cut lines by an order of magnitude more than required for the road, for example: for the road - 0.0001, and for the buffer 2 - 0.0003;

3) Extract points from it, while from a number of located points, create centroids;

4) Run the external points (from the buffer 2) the "Delaunay triangulation" tool;

5) Delone polygons in the Delone line and break them;

6) from the center line of the road, extract your points and create small buffers on them;

7) Select from the Delaunay lines, those that fall into the buffer points;

8) from the result 7, cut the road (buffer 1) into almost equal parts, and you will succeed, :-),

Cyril Mikhalchenko
  • 4,397
  • 7
  • 14
  • 45