LineStrings must not overlap
Overlapping lines are hard to find usually because you cannot see them on a map. They might be deliberate, for example, bus route network lines that might overlap. This exercise sets out to discover these overlapping lines for better or for worse.
The following diagram shows a set of two input LineStrings and you can see clearly where they overlap, but this is a cartographic visual inspection. We need this to work on many, many lines that you cannot always see as clearly.
How to do it...
Let's dive into the code:
#!/usr/bin/env python # -*- coding: utf-8 -*- from utils import shp2_geojson_obj from utils import create_shply_multigeom from utils import out_geoj in_shp_line = "../geodata/topo_line.shp" in_shp_overlap = "../geodata/topo_line_overlap.shp" shp1_data = shp2_geojson_obj(in_shp_line) shp2_data = shp2_geojson_obj(in_shp_overlap) shp1_lines = create_shply_multigeom(shp1_data, "MultiLineString") shp2_lines_overlap = create_shply_multigeom(shp2_data, "MultiLineString...