I have a VectorTile basemap that I am optimizing, (working on reducing the size of individual tiles), the major chunk of tile size is road data (geometry and attributes). I am working on simplifying the individual road geometries based on the Zoom Level, and aggregating the roads based on zoom levels as well.

The roads are stored in a Postgis table ( individual table for each zoom level ) and I want to aggregate the roads based on the zoom level they will be displayed at. For example, In the Zoom Level 5 table I want to aggregate the roads that are within a certain distance of one another, and make a single line for the road segments: enter image description here

Since it is not possible to make out individual roads at that zoom level: enter image description here

How can I aggregate the road geometries based on the distance between road segments?

PS: I am working on PostGIS and QGIS on Linux, but I am open to solutions using any Open Source platform or technology

  • Do the roads have a common ID e.g. two lanes at zoom level 5 on the A50 is represented by two lines, but at level 4 by one lin and they all have "A50" as their attribute?
    – AnserGIS
    Commented Sep 26, 2017 at 7:12
  • They are represented by two lines at all zoom levels. They highways and motorways will have the common attribute like "M-2" for the Motorways. Commented Sep 26, 2017 at 7:14

2 Answers 2


You could try looking int this OS option, Skeletron, it:

generalizes collections of lines to a specific spherical mercator zoom level and pixel precision, using a polygon buffer and voronoi diagram

It is based off of a 1996 paper by Alnoor Ladak and Roberto B. Martinez, "Automated Derivation of High Accuracy Road Centrelines Thiessen Polygons Technique"

There are some dependecies required:

Required dependencies:
- qhull binary (http://www.qhull.org)
- shapely 1.2+ (http://pypi.python.org/pypi/Shapely)
- pyproj (http://code.google.com/p/pyproj)
- networkx 1.5+ (http://networkx.lanl.gov)
- StreetNames 0.1+ (https://github.com/nvkelso/map-label-style-manual/tree/master/tools/street_names)

Note: This is an older model/tool that can be applied, just as a reference for you to explore.

  • 1
    I think skeletron could be the way to go, but your reply is juste a copy past of the readme file and the link to the esri website is dead. Here a link to show what it does for maps : kartographie.geo.tu-dresden.de/downloads/ica-gen/workshop2004/…. that look really great but when I try to use it I didnot known how to use it. I didnot found a documentation except some bribes with the use or setup.py --help command ... If someone explain how use that lib I give him the bounty. Commented Sep 27, 2017 at 18:09
  • Also it uses OSM roads as in input as far as I can see, I want a solution that can work on any type of line. Still, I really love the science behind it, would love to apply this to other scenarios as well. Commented Sep 28, 2017 at 6:47
  • I've updated my posted to reflect your comments, I appreciate the feedback.
    – whyzar
    Commented Sep 28, 2017 at 13:21

ArcGIS is the simplest if it is at all an option. I know the OP specifies OS but I mention this as the OS options just don't look very helpful compared to : http://resources.arcgis.com/en/help/main/10.1/index.html#/Merge_Divided_Roads/00700000000w000000/

Answers to this question give some Open Source options : How can I merge/collapse nearby and parallel road lines (eg. a dual-carriageway) into one single line?

If you code you could calculate the mean coordinate position on a vertex basis, if not then:

  1. buffer the roads with a "merge all" option on the output.
  2. Get the centre line of the polygon
  3. Split the lines at junctions with JUMP Split Lines at Intersection of Other Lines
  4. Spatial Join the attributes back on

There doesn't seem to be a good OS equivalent to ArcGIS 'Polygon to Centre line' tool either. I might suggest :

a. Create voronoi diagram and take the skeleton.
b. Create a Euclidean distance raster and extract the central value and convert to a line

... probably some others as well.

Finally, depending on the scale and application.. it might also be worth just deleting one of the two lines - will the imprecision matter?

  • The ArcGIS option looks good, I will give it a shot, but I would prefer an OS solution. Calculating the mean coordinate position on a vertex basis, is my fall-back strategy. I will try all the methods you have listed and see if they work for me, thanks! Commented Sep 26, 2017 at 7:55
  • The ArcGIS tool, ' Merge Divided Roads (Cartography) ', is exactly what I am looking for, but all the processing I am doing is on Linux, using Postgres and QGIS, to use the tool I will need to make the switch to windows. Commented Sep 27, 2017 at 10:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.