Network utilities

OpenStreetMap way filter

mtldp.mtlmap.osm_way_filter(file_name, customized_filter=None, output_file='filtered.osm')
Filter the osm way according the customized_filter

the nodes in the selected ways will be saved automatically other irrelevant elements will be removed

Parameters
  • file_name – input file name (.xml or .osm)

  • customized_filter

  • output_file

Returns

Save network to .osm file

mtldp.mtlmap.save_network_to_xml(network, output_file, directed=True)

save network to osm xml file

Parameters
  • networkmimap.Network

  • output_file – location of the output xml file

  • directed – if true, output the segment instead since all segments are directed osm ways

Output network for visualization

mtldp.mtlmap.output_static_geometry_json(network, output_file=None, lat_ahead=True)

Input the network, output the json file to display. The output .json is used to display the network in the web-based visualization tool: [map web].

Parameters
  • networkmtldp.mtlmap.Network

  • output_file – if None, this will return the dict, else save to the file

  • lat_ahead – latitude ahead or longitude ahead

Returns

None if the output_file is not empty, otherwise this function will return the dict.

Convert .osm file to shapefile

mtldp.mtlmap.convert_osm_to_shp(osm_file, output_folder, fastmm=True, bidirectional=False, simplify=False, retain_all=True, encoding='utf-8')

Convert the OSM xml map to shapefile

This function requires the osmnx package

Reference:

Parameters
  • osm_file – str, path of the file

  • output_folder – str, path of the folder for output

  • fastmm – True to output the shapefile for the fast map matching

  • bidirectional – bool, True if the user wants to have bidirectional format, default False

  • simplify – bool, True if the user wants to simplify the result, default False

  • retain_all

  • encoding – str, default “utf-8”

Returns

None

Return type

None