Coder Social home page Coder Social logo

osm2gmns's Introduction

osm2gmns

Authors: Jiawei Lu, Xuesong (Simon) Zhou

osm2gmns is an open-source Python package that enables users to conveniently obtain and manipulate any networks from OpenStreetMap (OSM). With a single line of Python code, users can obtain and model drivable, bikeable, walkable, railway, and aeroway networks for any region in the world and output networks to CSV files in GMNS format for seamless data sharing and research collaboration. osm2gmns mainly focuses on providing researchers and practitioners with flexible, standard and ready-to-use multi-modal transportation networks, as well as a bunch of customized and practical functions to facilitate various research and applications on traffic modeling.

Publication

Lu, J., & Zhou, X.S. (2023). Virtual track networks: A hierarchical modeling framework and open-source tools for simplified and efficient connected and automated mobility (CAM) system design based on general modeling network specification (GMNS). Transportation Research Part C: Emerging Technologies, 153, 104223. paper link

Main Features

  • Obtain any networks from OSM. osm2gmns parses map data from OSM and output networks to csv files in GMNS format.
  • Standard network format. osm2gmns adopts GMNS as the network format for seamless data sharing and research collaboration.
  • Ready-to-use network. osm2gmns cleans erroneous information from osm map data and is able to fill up critical missing values, i.e., lanes, speed and capacity, to quickly provide ready-to-use networks.
  • Directed network. two directed road links are generated for each bi-directional osm ways identified by osm2gmns
  • Multi-module support. five different network types are supported, including auto, bike, walk, railway, and aeroway
  • Customized and practical functions to facilitate traffic modeling. functions include complex intersection consolidation, moevement generation, traffic zone creation, short link combination, network visualization.
  • Multi-Resolution modeling. osm2gmns automatically construct the corresponding mesoscopic and microscopic networks for any macroscopic network in GMNS format.

Installation

pip install osm2gmns

If you meet installation issues, please refer to the user's guide for solutions.

Simple examples

You can find the osm map file used in the examples below at 'sample networks/Arizona State University, Tempe Campus'

Quickly get the network with point of interest (POI) information from an osm file

>>> import osm2gmns as og
>>> net = og.getNetFromFile('asu.osm', POI=True)
>>> og.outputNetToCSV(net)

Generate multi-resolution networks from an osm file

>>> import osm2gmns as og
>>> net = og.getNetFromFile('asu.osm')
>>> og.consolidateComplexIntersections(net, auto_identify=True)
>>> og.buildMultiResolutionNets(net)
>>> og.outputNetToCSV(net)

Get relation id of a place of interest and download the corresponding osm file

You can use the following code to get the relation id of a place of interest and download the corresponding osm file.

>>> import osm2gmns as og
# get relation id of a place of interest
# For the place of interest, e.g. Arizona State University
# e.g. "Tempe, Arizona, United States"
# e.g. "Arizona, US"
# e.g. "Beijing Jiaotong University, Beijing, China"
>>> rel_id = og.getOSMRelationID('Arizona State University')
>>> rel_id
    Info: Found relation id 3444656 from web
    Info: location of the place of interest:
    {
        "place_id": 318528634,
        "licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
        "osm_type": "relation",
        "osm_id": 3444656,
        "lat": "33.4213174",
        "lon": "-111.93316305413154",
        "class": "amenity",
        "type": "university",
        "place_rank": 30,
        "importance": 0.5547365758311374,
        "addresstype": "amenity",
        "name": "Arizona State University",
        "display_name": "Arizona State University, 1151, South Forest Avenue, Tempe Junction, Tempe, Maricopa County, Arizona, 85281, United States",
        "boundingbox": [
            "33.4102062",
            "33.4329786",
            "-111.9411651",
            "-111.9092447"
        ]
    }
3444656

# download the corresponding osm file
>>> og.downloadOSMData(rel_id, 'asu.osm')

User's guide

You can check the user's guide for a detailed introduction of osm2gmns.

osm2gmns's People

Contributors

jamiecook avatar jiawlu avatar orietrans avatar xyluo25 avatar zhiweiusf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

osm2gmns's Issues

AttributeError: module 'osm2gmns' has no attribute 'connectPOIWithNet'

Hi, everyone.
The latest version of osm2gmns that I've got (by 'pip install osm2gmns') was 0.6.3, this error appear:
AttributeError: module 'osm2gmns' has no attribute 'connectPOIWithNet'

I did the downgrade to 0.6.2 and I got the same error. My code was:

import osm2gmns as og 
net = og.getNetFromOSMFile('cefet_ns.osm', default_lanes=True, POI=True)
og.connectPOIWithNet(net)
og.generateNodeActivityInfo(net)
og.consolidateComplexIntersections(net)
og.generateMovements(net)
og.outputNetToCSV(net)
og.show(net)

PS.: I'm using PyCharm to process. The argument 'POIs' (in the second line of the code), as it is in the documentation bring another error:
net = og.getNetFromOSMFile('cefet_ns.osm', default_lanes=True, POIs=True)
TypeError: getNetFromOSMFile() got an unexpected keyword argument 'POIs'
After use 'POI' the argument error disappear.

Something has changed on the use of connectPOIWithNet?

Add a function to bring in pre-existing zone boundaries for the centroid connector creation

Hi Jiawei,

Typically, the zone-to-node mapping is specified in node.csv through the field of zone_id. However, there is a challenge when mapping TAZ-based information to the network. Please add a function to map TAZ centroid to node, and update zone_id field when users have TAZ boundary information, including boundary polygon, centroid latitude and longitude.

Dr. Zhou asked me prepare the phoenix network and TAZ files for your test.
The attached TAZ.csv contains fields for zone_id, x_coord, y_coord, and geometry defined in WKT format. The geometry is typically represented using polygon geometry and a pair of x_coord and y_coord defines zone centroids.

TAZ.csv
link.csv
node.csv

print out the total processing time at the end of the process

Currently, only the information below is given, but we need to know the total processing time for large networks. --
Building Network from OSM file
reading osm file
parsing osm network
generating nodes and links
number of nodes: 52820, number of links: 75395, number of pois: 0
Consolidating Complex Intersections
1324 intersections have been consolidated
Outputting Network Files

Questions/Edits Angelina

What does "Configuration information and use definitions" mean for GMNS static models?
What is a "connector link" - mesoscopic modeling?
In table for microscopic modeling, the id of its parent macroscopic link is included; can there be multiple parent links? How will this information be used?

Enhancing Zone ID Generation in OSM2GMNS: Integrating TAZ Files for MPO Planning

The current zone_id field in node.csv is generated based on activity types and boundary statistics from osm2gmns, and the zone IDs are assigned sequentially. For MPO planning users, they have their own TAZ files or zone centroids. I suggest integrating the taz2zone() from grid2demand function directly into osm2gmns og.generateNodeActivityInfo(net). We can add an additional parameter for zone.csv so that the zone_id in node.csv can be rewritten based on the nearest zone_id, determined by the geometry or point coordinates of each zone. This approach seems the most natural way to complete the function. One can test this feature using the standard Chicago sketch network or the Sioux Falls 24-node network. that is, the Chicago sketch network's zone_id system will be used in the osm2gmns generated node.csv and the readily available demand.csv file from Chicago sketch can be used further traffic assignment.

comments should be completed

我查看了源代码,发现几乎没有注解用来描述类和方法的功能,作为一个开源项目,这应该被完善。
I checked the source code and found that there were few comments to describe the functions of classes and methods, which should be supplied as an open source project.

amenity filter and externally given poi file

the current function: net = og.getNetFromFile('asu.osm', POI=True)
might lead to many records.

We hope to have net = og.getNetFromFile('asu.osm', POI=True, amenity_type=("parking", "parking_space") to only extract specified type of amenity. similar to network_types=('auto', "bike", "walk")

In addition, if the users manually filter out the data the in poi.csv, then og.connectPOIWithNet(net) should be enhanced to read the externally given poi csv file, similar to node_file='node.csv',

i.e. og.connectPOIWithNet(net, poi_file = "poi.csv")

those functions are important to ev charging space planning and multimodal city planning.

plan for document?

the document is out of date, do you have a plan to renew the document?

Retrieving additional fields from OSM

For many use cases, it is important to get information on additional tags from OSM. One example is to identify tunnels and bridges.

So, ideally, the API would allow for something like:

og.getNetFromFile("asu.osm.pbf", tags=["bridge", "tunnel"])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.