Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

osm_parser.py

Source: gist

haversine(lon1, lat1, lon2, lat2, unit_m=True)

Description:

Calculate the great circle distance between two points

Parameters:

Returns:


download_osm(left, bottom, right, top, proxy=False, proxyHost='10.0.4.2', proxyPort='3128', cache=False, cacheTempDir='/tmp/tmpOSM/', verbose=True)

Description:

Downloads OpenStreetMap data for a given bounding box.

Parameters:

Returns:


read_osm(filename_or_stream, only_roads=True)

Description:

Read graph in OSM format from file specified by name or by stream object.

Parameters:

Returns:

Examples:

G = nx.read_osm(nx.download_osm(-122.33, 47.60, -122.31, 47.61))
import matplotlib.pyplot as plt
plt.plot([G.node[n]['lat'] for n in G], [G.node[n]['lon'] for n in G], 'o', color='k')
plt.show()

Description:

Returns a GeoDataFrame of OSM roads from an OSM file

Parameters:

Returns:


line_length(line, ellipsoid='WGS-84')

Description:

Returns length of a line in kilometers, given in geographic

Parameters:

Returns:


Class Node

Represents a node in the OpenStreetMap data.

Class Way

Represents a way in the OpenStreetMap data.

Way.split(dividers)

Description:

Splits the way into multiple smaller ways based on the given dividers.

Parameters:

Returns:


Class OSM

Represents an OpenStreetMap (OSM) data structure.