Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Geospatial Analysis Cookbook

You're reading from   Python Geospatial Analysis Cookbook Over 60 recipes to work with topology, overlays, indoor routing, and web application analysis with Python

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher
ISBN-13 9781783555079
Length 310 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (15) Chapters Close

Preface 1. Setting Up Your Geospatial Python Environment FREE CHAPTER 2. Working with Projections 3. Moving Spatial Data from One Format to Another 4. Working with PostGIS 5. Vector Analysis 6. Overlay Analysis 7. Raster Analysis 8. Network Routing Analysis 9. Topology Checking and Data Validation 10. Visualizing Your Analysis 11. Web Analysis with GeoDjango A. Other Geospatial Python Libraries
B. Mapping Icon Libraries
Index

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...

  1. 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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime