Skip to main content

GitHub Actions Workflow Status GitHub license codecov PyPI pyversions PyPi Version

Taxicab

When routing between two points of longitude and latitude, the built in routing functionality in OSMnx will find the nearest network nodes and route between those. This assumption is fine, and works for many applications but when you need routing with a little more accuracy you'll want to consider using Taxicab. Below are a few examples which highlight Taxicab use cases:

When the nearest nodes are not that close:

When routing along a single edge:

When routing along short routes:

When the nearest nodes are the same:

Installation

The easiest way to use Taxicab is probably via a PyPi install:

pip install taxicab

You can also install directly from this repo:

pip install git+https://github.com/nathanrooy/taxicab

Example usage

Taxicab is designed to be used as a drop-in replacement for the standard routing functionality found on OSMnx. So, like usual, download a portion of the OpenStreetMap graph:

from osmnx import graph_from_bbox
xmin, xmax = -84.323, -84.305
ymin, ymax =  39.084,  39.092
G = graph_from_bbox([xmin, ymin, xmax, ymax], network_type='drive', simplify=True)

Now, specify your origin and destination:

orig = (39.0871, -84.3105)
dest = (39.0880, -84.3200) 

Compute the route via the following:

import taxicab as tc
route = tc.distance.shortest_path(G, orig, dest)

Which can then be plotted:

tc.plot.plot_graph_route(G, route)

The returned route is a named tuple comprised of four elements:

  • Route length in meters (or whatever your graph units are).
>>> route.length
669.0529395595279
  • List of node IDs representing the bulk of the route (this is identical to OSMnx).
>>> route.nodes
[197546973, 2090608743, 197656382, 197633479]
  • And two partial edges represented by shapely.geometry.linestring.LineString objects. If populated, these represent the first and last segments of the route that extend from the first or last node to some point along that edge.
>>> route.orig_edge, route.dest_edge
(<shapely.geometry.linestring.LineString at 0x7f1aa08067c0>,
 <shapely.geometry.linestring.LineString at 0x7f1a3ccbd580>)

User reference

taxicab.distance.shortest_path(G, orig, dest)

Parameters:

  • G : (networkx.MultiDiGraph) - input graph
  • orig : (tuple) - a (lat, lng) or (y, x) point
  • dest : (tuple) - a (lat, lng) or (y, x) point

Returns: (named tuple)

  • route.length : float - distance in meters of computed route.
  • route.nodes : path - list of node IDs constituting the shortest path (this is identical to routes found in OSMnx).
  • route.orig_edge : shapely.geometry.linestring.LineString - a partial edge representing the first non-complete edge in the route.
  • route.dest_edge : shapely.geometry.linestring.LineString - a partial edge representing the last non-complete edge in the route.
  • Note that if a route is successfully computed the distance will always be returned. However, depending on the length of the route and the underlying network, route.nodes, route.orig_edge, or route.dest_edge may be None.
taxicab.plot.plot_graph_route()

Used exactly the same way as osmnx.plot.plot_graph_route except that it uses the route (named tuple) produced by Taxicab instead. See OSMnx function reference [here]

Metadata

Release files for Taxicab 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Taxicab 0.1.2
File Size Uploaded Provenance Actions
taxicab-0.1.2.tar.gz 9.2 kB Without provenance Details for taxicab-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for Taxicab 0.1.2
File Interpreter ABI Platform Actions
taxicab-0.1.2-py3-none-any.whl Python 3 none any Details for taxicab-0.1.2-py3-none-any.whl

Total release size: 18.2 kB

Release files / taxicab-0.1.2.tar.gz

Download URL taxicab-0.1.2.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1ab63c497d87d1c38fc0c0367119eeade727b570cb111a40f0dd633d9d7c4cc6
BLAKE2b-256 checksum
How to use checksums
736e2d7343d789bc4c7c30660cd60b6c33e444e1add64bb44c161e143384e6d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / taxicab-0.1.2-py3-none-any.whl

Download URL taxicab-0.1.2-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c00c18bd91d7d998809d01d2cd1cc2f829720efba712d18571f9929d5581e186
BLAKE2b-256 checksum
How to use checksums
ef674f45f1ec61522546a4e8b500a0b224609978e911d2656a51d5058840416c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for Taxicab 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page