zoukankan      html  css  js  c++  java
  • Get A Transportation Network From OSMFile

    # Obtain a transportation network from an osm file.
    # get  osm file 方式1:OpenStreetMap Homepage
    # .osm.pbf下载地址 方式2:http://download.openstreetmap.fr/extracts/asia/china/
    # get  osm file 方式3:Geofabrik  https://download.geofabrik.de/
    # get  osm file 方式4: BBBike(可支持多边形范围) https://extract.bbbike.org/
    
    import osm2gmns as og
    import osm2gmns.settings as defaultsettings
    # pip install -i http://mirrors.aliyun.com/pypi/simple/ osm2gmns --trusted-host mirrors.aliyun.com
    
    # FromOSMFile
    # net = og.getNetFromOSMFile(r'D:/DataWorkspace/data/beijing.osm',
    #                       network_type=('auto',), link_type='all',
    #                       POIs=False, POI_sampling_ratio=1.0,
    #                       strict_mode=True,
    #                       offset='no',
    #                       min_nodes=1,
    #                       combine=False,
    #                       int_buffer=defaultsettings.default_int_buffer,
    #                       bbox=None,
    #                       default_lanes=False,
    #                       default_speed=False)
    
    # FromPBFFile
    net = og.getNetFromPBFFile(r'D:/DataWorkspace/data/beijing.osm.pbf',
                               network_type=('auto',), link_type='all',
                               POIs=False, POI_sampling_ratio=1.0,
                               strict_mode=True,
                               offset='no',
                               min_nodes=1,
                               combine=False,
                               int_buffer=defaultsettings.default_int_buffer,
                               bbox=None,
                               default_lanes=False,
                               default_speed=False)
    # Recommend using getNetFromPBFFile() for large networks
    # net = og.getNetFromPBFFile('***.osm.pbf')
    
    default_lanes_dict = {'motorway': 4, 'trunk': 3, 'primary': 3, 'secondary': 2, 'tertiary': 2,
                          'residential': 1, 'service': 1, 'cycleway':1, 'footway':1, 'track':1,
                          'unclassified': 1, 'connector': 2}
    default_speed_dict = {'motorway': 59, 'trunk': 39, 'primary': 39, 'secondary': 39, 'tertiary': 29,
                          'residential': 29, 'service': 29, 'cycleway':9, 'footway':4, 'track':29,
                          'unclassified': 29, 'connector':59}
    
    # 保存成CSV Output Networks to CSV
    og.outputNetToCSV(net, output_folder='netcsv', projection=False, enconding=None)
    
    # 合并交叉路口 Consolidate Intersections
    og.consolidateComplexIntersections(net)
    og.outputNetToCSV(net, output_folder='netcsv_csd', projection=False, enconding=None)
    
    # # 也可以先保存成csv,然后人工编辑,最后再合并
    # net = og.getNetFromPBFFile(r'D:/DataWorkspace/data/beijing.osm.pbf')
    # og.outputNetToCSV(net, output_folder='', projection=False, enconding=None)
    # # check the main_node_id column in node.csv
    # net = og.getNetFromCSV(folder='', enconding=None)
    # og.consolidateComplexIntersections(net)
    # og.outputNetToCSV(net, output_folder='consolidated', projection=False, enconding=None)
    
    # # 连接POI
    # # Network with POIs
    # net = og.getNetFromPBFFile(r'D:/DataWorkspace/data/beijing.osm.pbf',
    #                            network_type=('auto',), link_type='all',
    #                            POIs=True, POI_sampling_ratio=1.0,
    #                            strict_mode=True,
    #                            offset='no',
    #                            min_nodes=1,
    #                            combine=False,
    #                            int_buffer=defaultsettings.default_int_buffer,
    #                            bbox=None,
    #                            default_lanes=False,
    #                            default_speed=False)
    # # Connect POIs with network
    # og.connectPOIWithNet(net)
    
    # Visualization
    # You can visualize generated networks using NeXTA or QGis.
    # NeXTA:https://github.com/xzhou99/NeXTA-GMNS OR https://github.com/asu-trans-ai-lab/DTALite

     贴几张图吧  记录而已

     

     

     

     

     

    个人学习记录
  • 相关阅读:
    C语言 sprintf 函数 C语言零基础入门教程
    C语言 printf 函数 C语言零基础入门教程
    C语言 文件读写 fgets 函数 C语言零基础入门教程
    C语言 文件读写 fputs 函数 C语言零基础入门教程
    C语言 fprintf 函数 C语言零基础入门教程
    C语言 文件读写 fgetc 函数 C语言零基础入门教程
    C语言 文件读写 fputc 函数 C语言零基础入门教程
    C语言 strlen 函数 C语言零基础入门教程
    Brad Abrams关于Naming Conventions的演讲中涉及到的生词集解
    适配器模式
  • 原文地址:https://www.cnblogs.com/jeshy/p/14853969.html
Copyright © 2011-2022 走看看