Skip to main content

This library provides a set of tools for generating isochrones from geographic coordinates. It leverages OpenStreetMap data to construct road networks and calculate areas accessible within specified time limits. The library is designed for both Rust and Python, offering high performance and easy integration into data science workflows.

Project description

OSM_graph

Quickly generate isochrones for Python and Rust!

This library provides a set of tools for generating isochrones and reverse isochrones from geographic coordinates. It leverages OpenStreetMap data to construct road networks and calculate areas accessible within specified time limits. The library is designed for both Rust and Python, offering high performance and easy integration into data science workflows.

Isochrones

Features

  • Graph Construction: Parses OpenStreetMap data to construct a graph representing the road network.
  • Graph Simplification: Topologically simplifies the graph by collapsing linear chains and deduplicating parallel edges, reducing node/edge count by ~89% for faster downstream computation.
  • Spatial Indexing: R-tree spatial index for O(log n) nearest-node lookups, built once and reused for all queries.
  • Isochrone Calculation: Generates isochrones using a single Dijkstra traversal, with hull computation parallelized across time limits.
  • Concave and Convex Hulls: Supports generating both concave and convex hulls around isochrones for more accurate or simplified geographical shapes.
  • Caching: Two-level cache (raw OSM XML + built graphs) so repeated queries for the same area require no network calls.
  • Python Integration: Offers Python bindings to use the library's functionalities directly in Python scripts, notebooks, and applications.
  • Concurrency Support: Utilizes Rust's concurrency features for efficient isochrone calculation over large datasets.
  • GeoJSON Output: Converts isochrones into GeoJSON format for easy visualization and integration with mapping tools.

Installation

To use the library in Rust, add it to your Cargo.toml:

[dependencies]
osm-graph = "0.1.0"

For Python,

pip install pysochrone

Or, ensure you have Rust and maturin installed, then build and install the Python package:

maturin develop

Usage

Rust

use osm_graph::isochrone::{calculate_isochrones_from_point, HullType};
use osm_graph::overpass::NetworkType;

#[tokio::main]
async fn main() {
    let (isochrones, _graph) = calculate_isochrones_from_point(
        48.123456,
        11.123456,
        10_000.0,
        vec![300.0, 600.0, 900.0, 1_200.0, 1_500.0, 1_800.0],
        NetworkType::Drive,
        HullType::Convex,
        false, // false = simplified graph (faster), true = full graph
    )
    .await
    .unwrap();
}

Python

import pysochrone

isochrones = pysochrone.calc_isochrones(
    48.123456,   # lat
    11.123456,   # lon
    10_000,      # bounding box radius in meters
    [300, 600, 900, 1200, 1500, 1800],  # time limits in seconds
    "Drive",     # network type: Drive | DriveService | Walk | Bike | All | AllPrivate
    "Concave",   # hull type: Convex | FastConcave | Concave
    False,       # optional: False = simplified (default), True = full graph
)

Roadmap

  • Testing and benchmarks.
  • Customizable Speed Limits: Allow users to specify custom speed limits for different road types.
  • Support for Pedestrian and Bicycle Networks: Expand the graph construction to support pedestrian and bicycle network types.
  • Topological simplification of osm graphs for more efficient downstream analytics.
  • Additional Roadnetwork analytics.
  • Routing engine.
  • Advanced Caching Strategies: Implement more sophisticated caching mechanisms for dynamic query parameters.
  • Interactive Visualization Tools: Develop a set of tools for interactive visualization of isochrones in web applications.
  • API Integration: Provide integration options with third-party APIs for enhanced data accuracy and features.
  • Optimization and Parallel Computing: Further optimize the graph algorithms and explore parallel computing options for large-scale data.

Contributing

Contributions are welcome! Please submit pull requests, open issues for discussion, and suggest new features or improvements.

License

This library is licensed under MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysochrone-0.1.2.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysochrone-0.1.2-cp310-none-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file pysochrone-0.1.2.tar.gz.

File metadata

  • Download URL: pysochrone-0.1.2.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.5

File hashes

Hashes for pysochrone-0.1.2.tar.gz
Algorithm Hash digest
SHA256 85a0e011fec1dee48cbcef3239c6b64570cda17345c064d9b5668fd9bf37825d
MD5 f1bb99bf5b2463b1e762702a5b381626
BLAKE2b-256 602c2282e50d875e088361bcf76716ce85aab72d3a8f0d71e3f04bc4eda5e4b5

See more details on using hashes here.

File details

Details for the file pysochrone-0.1.2-cp310-none-win_amd64.whl.

File metadata

  • Download URL: pysochrone-0.1.2-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.5

File hashes

Hashes for pysochrone-0.1.2-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 2bdf24b033fa9aeb404f4ebcc7c71a11ee22d596452f380bf90818a46ceebb2f
MD5 1b5c0232d6dad7937d8695275c10a36c
BLAKE2b-256 107bbb8af168b36ec59bd0a02a4b88fca6c9b3119cb96af7247d3852b1875e90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page