[GIS] Automatic bus route map without overlaps

cartographyparallel linesqgis

I'm working with drawing maps of all bus routes in a defined area (municipality) in QGIS. I have a problem about showing two routes with the geometry (the same road) parallel. I know it's possible to do it manually (line offset). Is it possible to do automatically?

Standard viewDesired view

Best Answer

Your task is directly related to the task of visualizing geodata and nothing else (the names of the tables are abstract).

There are many ways to solve this problem, my solution is as follows:

The initial data, if I correctly understand the statement of your problem, are presented in Figure 1

enter image description here

I have in the boundaries_exper2 table two objects of the LineString type gid1 line on the left and the gid2 line on the right, you have two separate layers (tables).

1) Having calculated the values of your distance from the main route,   in pgAdmin run the query:

create table boundaries_exper3 as SELECT ST_OffsetCurve (geom, 0.001) geom FROM exper_linestrings WHERE gid = 1;

The result is a parallel line with an indented line from the line with gid = 1

For an example, see Figure 2

enter image description here

2) Next you need to define the intersection point of the created parallel line with the adjacent to the main line (the line on the left) in pgAdmin run the query:

create table boundaries_exper4 as SELECT ST_Intersection (boundaries_exper2.geom, boundaries_exper3.geom) geom FROM boundaries_exper2.geom, boundaries_exper3 WHERE ST_Crosses (boundaries_exper2.geom, boundaries_exper3.geom);

The result is shown in Figure 3.

enter image description here

3) Next from all your lines, create a point type from the line type, for this, run the following query in pgAdmin:

create table exper_line_to_poi as SELECT (ST_Dumppoints (geom)).geom FROM boundaries_exper2; The result, see Figures 4 and 5 respectively

enter image description here

enter image description here

4) In the mode of editing the point table exper_line_to_poi_paral, delete all points that lie in the left area, copy the intersection point from the boundaries_exper4 layer and add it to the layer of processed points and from them create the line with the following code:

create table exper_poi_to_line_paral as SELECT st_makeline (geom) geom FROM exper_line_to_poi_paral; The result is shown in Figure 6.

enter image description here

5) Create 2 more lines 1 of the two points, namely the intersection point and the starting point of the adjacent line and from the points of the adjacent line (reference lines), create the line with the following codes:

create table exper_line_to_poi5 as SELECT st_makeline (geom) geom FROM exper_poi3; and

create table exper_line_to_poi6 as SELECT st_makeline (geom) geom FROM exper_line_to_poi3; The result should be as follows, see figure 7

enter image description here

6) Combine the three linear tables into one by running the code:

create table exper_line_union as SELECT * FROM exper_poi_to_line_paral UNION ALL SELECT * FROM exper_line_to_poi5 UNION ALL SELECT * FROM exper_line_to_poi6 and add the main route,

The result is shown in Figure 8

enter image description here