Skip to main content
1 of 4
MartinMap
  • 8.4k
  • 7
  • 53
  • 119

Virtual layer: Group lines by name and determine their proportions

I have a line layer with hiking trails. The hiking trails are divided into their surfaces. So one hiking trail consist of parts with different surfaces.

I would like to use a virtual layer to group the trails by their name and determine the proportions of the path surfaces (in distance and percentage).

Example: Route A 20km/100%: 5km/25% grade-A, 10km/50% grade-B, 5km/25% grade-C

The very simple SQL-Querry for grouping and summing the parts for every trail is:

SELECT name, sum(length) AS Length, ST_Union(geometry) geom FROM Trails GROUP BY name;
MartinMap
  • 8.4k
  • 7
  • 53
  • 119