Book Image

Python Geospatial Analysis Cookbook

Book Image

Python Geospatial Analysis Cookbook

Overview of this book

Table of Contents (20 chapters)
Python Geospatial Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Other Geospatial Python Libraries
Mapping Icon Libraries
Index

A LineString must not have dangles


Dangles are like cul-de-sac (roads). You can find them only in LineStrings where a line ends and does not connect to another line segment. "To dangle in the air" refers to a LineString that is not connected to any other LineString. These are very important to identify if you are looking to ensure that a road network is connected or to identify where streets come together as they should.

A more technical description of a dangle could be described as an edge that has one or both ends that are not incidental to another edge endpoint.

How to do it...

  1. You will now check for dangles on your set of LineStrings as follows:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    from utils import shp2_geojson_obj
    from utils import create_shply_multigeom
    from utils import out_geoj
    from shapely.geometry import Point
    
    in_shp_dangles = "../geodata/topo_dangles.shp"
    shp1_data = shp2_geojson_obj(in_shp_dangles)
    shp1_lines = create_shply_multigeom(shp1_data, "MultiLineString")
    
    
    def...