Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Get Windows 11 Pro for $25 and actually learn how to use it

    Just $75 unlocks GPT-4o, Claude 3, Gemini & more for life

    Claude looks even better as free users get more features to play with

    Facebook X (Twitter) Instagram
    • Artificial Intelligence
    • Business Technology
    • Cryptocurrency
    • Gadgets
    • Gaming
    • Health
    • Software and Apps
    • Technology
    Facebook X (Twitter) Instagram Pinterest Vimeo
    Tech AI Verse
    • Home
    • Artificial Intelligence

      Read the extended transcript: President Donald Trump interviewed by ‘NBC Nightly News’ anchor Tom Llamas

      February 6, 2026

      Stocks and bitcoin sink as investors dump software company shares

      February 4, 2026

      AI, crypto and Trump super PACs stash millions to spend on the midterms

      February 2, 2026

      To avoid accusations of AI cheating, college students are turning to AI

      January 29, 2026

      ChatGPT can embrace authoritarian ideas after just one prompt, researchers say

      January 24, 2026
    • Business

      The HDD brand that brought you the 1.8-inch, 2.5-inch, and 3.5-inch hard drives is now back with a $19 pocket-sized personal cloud for your smartphones

      February 12, 2026

      New VoidLink malware framework targets Linux cloud servers

      January 14, 2026

      Nvidia Rubin’s rack-scale encryption signals a turning point for enterprise AI security

      January 13, 2026

      How KPMG is redefining the future of SAP consulting on a global scale

      January 10, 2026

      Top 10 cloud computing stories of 2025

      December 22, 2025
    • Crypto

      US Investors Might Be Leaving Bitcoin and Ethereum ETFs for International Markets

      February 14, 2026

      Binance France President Targeted in Armed Kidnapping Attempt

      February 14, 2026

      Binance Fires Investigators as $1 Billion Iran-Linked USDT Flows Surface

      February 14, 2026

      Aave Proposes 100% DAO Revenue Model, Yet Price Remains Under Pressure

      February 14, 2026

      A $3 Billion Credit Giant Is Testing Bitcoin in the Mortgage System — Here’s How

      February 14, 2026
    • Technology

      Get Windows 11 Pro for $25 and actually learn how to use it

      February 14, 2026

      Just $75 unlocks GPT-4o, Claude 3, Gemini & more for life

      February 14, 2026

      Claude looks even better as free users get more features to play with

      February 14, 2026

      Google Docs can now AI-generate audio summaries of your documents

      February 14, 2026

      Steam beta lets you add your PC specs to game reviews

      February 14, 2026
    • Others
      • Gadgets
      • Gaming
      • Health
      • Software and Apps
    Check BMI
    Tech AI Verse
    You are at:Home»Technology»Show HN: US Routing – Python library for fast local routing in the United States
    Technology

    Show HN: US Routing – Python library for fast local routing in the United States

    TechAiVerseBy TechAiVerseMay 8, 2025No Comments3 Mins Read3 Views
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Show HN: US Routing – Python library for fast local routing in the United States
    Share
    Facebook Twitter LinkedIn Pinterest WhatsApp Email

    Show HN: US Routing – Python library for fast local routing in the United States

    US Routing

    US Routing is a Python library for fast local routing in the United States. It’s useful when approximations are acceptable. It bootstraps from the North American Roads dataset.

    Installation

    You can install US Routing using pip:

    or using poetry:

    git clone https://github.com/ivanbelenky/us-routing.git
    cd us-routing
    poetry install

    Usage

    Here’s a quick example of how to use US Routing:

    POINT (-74.0013209995546 40.74648499998924) (0.5700000000000001 km) 9TH AV, SP_TH_MA, 72 km/h
    #POINT (-74.0013209995546 40.74648499998924) -> POINT (-74.0054249996425 40.74097199980971) (0.6799999999999999 km) 9TH AV, SP_TH_MA, 72 km/h
    #POINT (-74.0054249996425 40.74097199980971) -> POINT (-74.00819599956175 40.74211600011984) (0.27 km) W 14TH ST, SP_TH_MA, 72 km/h
    #POINT (-74.00819599956175 40.74211600011984) -> POINT (-74.0090509998795 40.74090099973697) (0.16 km) 10TH AV, SP_TH_MA, 72 km/h
    # …]

    # Route between zip codes
    r = get_route(‘10001’, ‘60007’)
    print(r.total_distance, r.duration)
    # Output:
    # 1315.910000000001 13:20:26.827392

    # Route between coordinates, will raise ValueError if closest node in the graph is too far from the location
    try:
    r = get_route((40.7128, -74.0060), (34.0522, -118.2437), d_threshold=0.00001)
    print(r.total_distance, r.duration)
    except ValueError as e:
    print(e)
    # Node 2bd87209-d2fe-4f41-a89f-29104aeb5cf9 is too far from location point= zip_code=None admin=None name=None

    r = get_route((-74.0060, 40.7128), (-118.2437, 34.0522), d_threshold=10)

    # and for sure you can mix stuff up
    r = get_route((40.7128, -74.0060), “seattle”, d_threshold=15)
    “>

    from us_routing import get_route
    
    # Route between two cities
    r = get_route('New York', 'Los Angeles', edge_distance="DURATION")
    print(r.total_distance, r.duration)
    # Output in km of course:
    # 4434.759999999997 1 day, 20:46:24.499959
    
    # Print route steps
    print(r)
    # Output: [
    #POINT (-73.99811899964011 40.7508730002449) -> POINT (-74.0013209995546 40.74648499998924) (0.5700000000000001 km) 9TH AV, SP_TH_MA, 72 km/h
    #POINT (-74.0013209995546 40.74648499998924) -> POINT (-74.0054249996425 40.74097199980971) (0.6799999999999999 km) 9TH AV, SP_TH_MA, 72 km/h
    #POINT (-74.0054249996425 40.74097199980971) -> POINT (-74.00819599956175 40.74211600011984) (0.27 km) W 14TH ST, SP_TH_MA, 72 km/h
    #POINT (-74.00819599956175 40.74211600011984) -> POINT (-74.0090509998795 40.74090099973697) (0.16 km) 10TH AV, SP_TH_MA, 72 km/h
    # ...]
    
    # Route between zip codes
    r = get_route('10001', '60007')
    print(r.total_distance, r.duration)
    # Output:
    # 1315.910000000001 13:20:26.827392
    
    
    # Route between coordinates, will raise ValueError if closest node in the graph is too far from the location
    try:
        r = get_route((40.7128, -74.0060), (34.0522, -118.2437), d_threshold=0.00001)
        print(r.total_distance, r.duration)
    except ValueError as e:
        print(e)
    #  Node 2bd87209-d2fe-4f41-a89f-29104aeb5cf9 is too far from location point= zip_code=None admin=None name=None
    
    r = get_route((-74.0060, 40.7128), (-118.2437, 34.0522), d_threshold=10)
    
    # and for sure you can mix stuff up
    r = get_route((40.7128, -74.0060), "seattle", d_threshold=15)

    Features

    • Fast routing between US locations (cities, zip codes, or coordinates)
    • Multiple routing options by default (shortest distance, fastest time)
    • Detailed route information (distance, duration, states traversed)

    Data Source

    The routing data is based on the North American Roads dataset. The library includes functionality to download and process this data:

    from us_routing import download_north_american_roads
    
    download_north_american_roads()

    Development

    To set up the development environment:

    1. Clone the repository
    2. Install Poetry: pip install poetry
    3. Install dependencies: poetry install

    Custom Routers

    This package provides a BaseRouter class that you can use to build your own custom routing graphs. It exposes a very simple API to create routers from shapefiles containing multiple geometries and optional attributes for those geometries. It looks something like this:

    geometries: Sequence[LineString | MultiLineString]
    geometries_data: Optional[Sequence[Dict[str, Any]]] = None # should be serializable
    
    # Optional arguments to define how attributes are compared and set to the edges of the graph
    edge_attr_equal: Optional[Callable[[Any, Any], bool]] = ...
    edge_attr_setter: Optional[Callable[[Any, Any], dict[str, Any]]] = ...
    
    router = BaseRouter.from_geometries(geometries, geometries_data, edge_attr_equal, edge_attr_setter)
    router.serialize("path_to_save")

    Contributing

    Contributions are welcome! Please feel free to submit a Pull Request.

    Share. Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Telegram Email
    Previous ArticleYggdrasil is an experimental compact routing scheme that is fully decentralised
    Next Article Parametric Modeling with Grasshopper
    TechAiVerse
    • Website

    Jonathan is a tech enthusiast and the mind behind Tech AI Verse. With a passion for artificial intelligence, consumer tech, and emerging innovations, he deliver clear, insightful content to keep readers informed. From cutting-edge gadgets to AI advancements and cryptocurrency trends, Jonathan breaks down complex topics to make technology accessible to all.

    Related Posts

    Get Windows 11 Pro for $25 and actually learn how to use it

    February 14, 2026

    Just $75 unlocks GPT-4o, Claude 3, Gemini & more for life

    February 14, 2026

    Claude looks even better as free users get more features to play with

    February 14, 2026
    Leave A Reply Cancel Reply

    Top Posts

    Ping, You’ve Got Whale: AI detection system alerts ships of whales in their path

    April 22, 2025671 Views

    Lumo vs. Duck AI: Which AI is Better for Your Privacy?

    July 31, 2025259 Views

    6.7 Cummins Lifter Failure: What Years Are Affected (And Possible Fixes)

    April 14, 2025153 Views

    6 Best MagSafe Phone Grips (2025), Tested and Reviewed

    April 6, 2025112 Views
    Don't Miss
    Technology February 14, 2026

    Get Windows 11 Pro for $25 and actually learn how to use it

    Get Windows 11 Pro for $25 and actually learn how to use it Image: StackCommerce…

    Just $75 unlocks GPT-4o, Claude 3, Gemini & more for life

    Claude looks even better as free users get more features to play with

    Google Docs can now AI-generate audio summaries of your documents

    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    About Us
    About Us

    Welcome to Tech AI Verse, your go-to destination for everything technology! We bring you the latest news, trends, and insights from the ever-evolving world of tech. Our coverage spans across global technology industry updates, artificial intelligence advancements, machine learning ethics, and automation innovations. Stay connected with us as we explore the limitless possibilities of technology!

    Facebook X (Twitter) Pinterest YouTube WhatsApp
    Our Picks

    Get Windows 11 Pro for $25 and actually learn how to use it

    February 14, 20262 Views

    Just $75 unlocks GPT-4o, Claude 3, Gemini & more for life

    February 14, 20261 Views

    Claude looks even better as free users get more features to play with

    February 14, 20262 Views
    Most Popular

    7 Best Kids Bikes (2025): Mountain, Balance, Pedal, Coaster

    March 13, 20250 Views

    VTOMAN FlashSpeed 1500: Plenty Of Power For All Your Gear

    March 13, 20250 Views

    This new Roomba finally solves the big problem I have with robot vacuums

    March 13, 20250 Views
    © 2026 TechAiVerse. Designed by Divya Tech.
    • Home
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms & Conditions

    Type above and press Enter to search. Press Esc to cancel.