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

Splitting LineStrings at intersections using ST_Node


Working with road data is usually a tricky business because the validity of the data and data structure plays a very important role. If you want to do anything useful with your road data, such as building a routing network, you will need to prepare the data first. The first task is usually to segmentize your lines, which means splitting all lines at intersections where LineStrings cross each other, creating a base network road dataset.

Note

Be aware that this recipe will split all lines on all intersections regardless of whether, for example, there is a road-bridge overpass where no intersection should be created.

Getting ready

Before we get into the details of how to do this, we will use a small section of the OpenStreetMap (OSM) road data for our example. The OSM data is available in your /ch04/geodata/folder called vancouver-osm-data.osm. This data was simply downloaded from the www.openstreetmap.org home page using the Export button located...