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 point must be on the starting and ending nodes of a line only


A routing network of connected edges may contain some routing logic associated with the intersections of roads that are represented as points. These points must, of course, be exactly located at the start or end of a line in order to identify these junctions. Once the junctions are found, various rules can be applied in the attributes to control your routing, for example.

A typical example would be turn restrictions that could be modeled as points:

How to do it...

Our handy utils.py module located in the trunk folder helps us out with the mundane tasks of importing a Shapefile and converting it to a Shapely geometry object for us to work with.

  1. Now let's create our point check code like this:

    #!/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, MultiPoint
    
    in_shp_line = "../geodata/topo_line.shp"
    in_shp_point...