partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | round_linestring_coords | Round the coordinates of a shapely LineString to some decimal precision.
Parameters
----------
ls : shapely LineString
the LineString to round the coordinates of
precision : int
decimal precision to round coordinates to
Returns
-------
LineString | osmnx/utils.py | def round_linestring_coords(ls, precision):
"""
Round the coordinates of a shapely LineString to some decimal precision.
Parameters
----------
ls : shapely LineString
the LineString to round the coordinates of
precision : int
decimal precision to round coordinates to
Return... | def round_linestring_coords(ls, precision):
"""
Round the coordinates of a shapely LineString to some decimal precision.
Parameters
----------
ls : shapely LineString
the LineString to round the coordinates of
precision : int
decimal precision to round coordinates to
Return... | [
"Round",
"the",
"coordinates",
"of",
"a",
"shapely",
"LineString",
"to",
"some",
"decimal",
"precision",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L1095-L1111 | [
"def",
"round_linestring_coords",
"(",
"ls",
",",
"precision",
")",
":",
"return",
"LineString",
"(",
"[",
"[",
"round",
"(",
"x",
",",
"precision",
")",
"for",
"x",
"in",
"c",
"]",
"for",
"c",
"in",
"ls",
".",
"coords",
"]",
")"
] | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | round_shape_coords | Round the coordinates of a shapely geometry to some decimal precision.
Parameters
----------
shape : shapely geometry, one of Point, MultiPoint, LineString,
MultiLineString, Polygon, or MultiPolygon
the geometry to round the coordinates of
precision : int
decimal precision t... | osmnx/utils.py | def round_shape_coords(shape, precision):
"""
Round the coordinates of a shapely geometry to some decimal precision.
Parameters
----------
shape : shapely geometry, one of Point, MultiPoint, LineString,
MultiLineString, Polygon, or MultiPolygon
the geometry to round the coordina... | def round_shape_coords(shape, precision):
"""
Round the coordinates of a shapely geometry to some decimal precision.
Parameters
----------
shape : shapely geometry, one of Point, MultiPoint, LineString,
MultiLineString, Polygon, or MultiPolygon
the geometry to round the coordina... | [
"Round",
"the",
"coordinates",
"of",
"a",
"shapely",
"geometry",
"to",
"some",
"decimal",
"precision",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L1135-L1171 | [
"def",
"round_shape_coords",
"(",
"shape",
",",
"precision",
")",
":",
"if",
"isinstance",
"(",
"shape",
",",
"Point",
")",
":",
"return",
"round_point_coords",
"(",
"shape",
",",
"precision",
")",
"elif",
"isinstance",
"(",
"shape",
",",
"MultiPoint",
")",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | overpass_json_from_file | Read OSM XML from input filename and return Overpass-like JSON.
Parameters
----------
filename : string
name of file containing OSM XML data
Returns
-------
OSMContentHandler object | osmnx/utils.py | def overpass_json_from_file(filename):
"""
Read OSM XML from input filename and return Overpass-like JSON.
Parameters
----------
filename : string
name of file containing OSM XML data
Returns
-------
OSMContentHandler object
"""
_, ext = os.path.splitext(filename)
... | def overpass_json_from_file(filename):
"""
Read OSM XML from input filename and return Overpass-like JSON.
Parameters
----------
filename : string
name of file containing OSM XML data
Returns
-------
OSMContentHandler object
"""
_, ext = os.path.splitext(filename)
... | [
"Read",
"OSM",
"XML",
"from",
"input",
"filename",
"and",
"return",
"Overpass",
"-",
"like",
"JSON",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L1217-L1243 | [
"def",
"overpass_json_from_file",
"(",
"filename",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"if",
"ext",
"==",
"'.bz2'",
":",
"# Use Python 2/3 compatible BZ2File()",
"opener",
"=",
"lambda",
"fn",
":",
"bz2",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | bbox_to_poly | Convenience function to parse bbox -> poly | osmnx/utils.py | def bbox_to_poly(north, south, east, west):
"""
Convenience function to parse bbox -> poly
"""
return Polygon([(west, south), (east, south), (east, north), (west, north)]) | def bbox_to_poly(north, south, east, west):
"""
Convenience function to parse bbox -> poly
"""
return Polygon([(west, south), (east, south), (east, north), (west, north)]) | [
"Convenience",
"function",
"to",
"parse",
"bbox",
"-",
">",
"poly"
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L1247-L1252 | [
"def",
"bbox_to_poly",
"(",
"north",
",",
"south",
",",
"east",
",",
"west",
")",
":",
"return",
"Polygon",
"(",
"[",
"(",
"west",
",",
"south",
")",
",",
"(",
"east",
",",
"south",
")",
",",
"(",
"east",
",",
"north",
")",
",",
"(",
"west",
",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | parse_poi_query | Parse the Overpass QL query based on the list of amenities.
Parameters
----------
north : float
Northernmost coordinate from bounding box of the search area.
south : float
Southernmost coordinate from bounding box of the search area.
east : float
Easternmost coordinate ... | osmnx/pois.py | def parse_poi_query(north, south, east, west, amenities=None, timeout=180, maxsize=''):
"""
Parse the Overpass QL query based on the list of amenities.
Parameters
----------
north : float
Northernmost coordinate from bounding box of the search area.
south : float
Southernmo... | def parse_poi_query(north, south, east, west, amenities=None, timeout=180, maxsize=''):
"""
Parse the Overpass QL query based on the list of amenities.
Parameters
----------
north : float
Northernmost coordinate from bounding box of the search area.
south : float
Southernmo... | [
"Parse",
"the",
"Overpass",
"QL",
"query",
"based",
"on",
"the",
"list",
"of",
"amenities",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L24-L65 | [
"def",
"parse_poi_query",
"(",
"north",
",",
"south",
",",
"east",
",",
"west",
",",
"amenities",
"=",
"None",
",",
"timeout",
"=",
"180",
",",
"maxsize",
"=",
"''",
")",
":",
"if",
"amenities",
":",
"# Overpass QL template",
"query_template",
"=",
"(",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | osm_poi_download | Get points of interests (POIs) from OpenStreetMap based on selected amenity types.
Parameters
----------
poly : shapely.geometry.Polygon
Polygon that will be used to limit the POI search.
amenities : list
List of amenities that will be used for finding the POIs from the selected area.
... | osmnx/pois.py | def osm_poi_download(polygon=None, amenities=None, north=None, south=None, east=None, west=None,
timeout=180, max_query_area_size=50*1000*50*1000):
"""
Get points of interests (POIs) from OpenStreetMap based on selected amenity types.
Parameters
----------
poly : shapely.geomet... | def osm_poi_download(polygon=None, amenities=None, north=None, south=None, east=None, west=None,
timeout=180, max_query_area_size=50*1000*50*1000):
"""
Get points of interests (POIs) from OpenStreetMap based on selected amenity types.
Parameters
----------
poly : shapely.geomet... | [
"Get",
"points",
"of",
"interests",
"(",
"POIs",
")",
"from",
"OpenStreetMap",
"based",
"on",
"selected",
"amenity",
"types",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L68-L107 | [
"def",
"osm_poi_download",
"(",
"polygon",
"=",
"None",
",",
"amenities",
"=",
"None",
",",
"north",
"=",
"None",
",",
"south",
"=",
"None",
",",
"east",
"=",
"None",
",",
"west",
"=",
"None",
",",
"timeout",
"=",
"180",
",",
"max_query_area_size",
"="... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | parse_nodes_coords | Parse node coordinates from OSM response. Some nodes are
standalone points of interest, others are vertices in
polygonal (areal) POIs.
Parameters
----------
osm_response : string
OSM response JSON string
Returns
-------
coords : dict
dict of node IDs and their ... | osmnx/pois.py | def parse_nodes_coords(osm_response):
"""
Parse node coordinates from OSM response. Some nodes are
standalone points of interest, others are vertices in
polygonal (areal) POIs.
Parameters
----------
osm_response : string
OSM response JSON string
Returns
-------
... | def parse_nodes_coords(osm_response):
"""
Parse node coordinates from OSM response. Some nodes are
standalone points of interest, others are vertices in
polygonal (areal) POIs.
Parameters
----------
osm_response : string
OSM response JSON string
Returns
-------
... | [
"Parse",
"node",
"coordinates",
"from",
"OSM",
"response",
".",
"Some",
"nodes",
"are",
"standalone",
"points",
"of",
"interest",
"others",
"are",
"vertices",
"in",
"polygonal",
"(",
"areal",
")",
"POIs",
".",
"Parameters",
"----------",
"osm_response",
":",
"... | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L110-L132 | [
"def",
"parse_nodes_coords",
"(",
"osm_response",
")",
":",
"coords",
"=",
"{",
"}",
"for",
"result",
"in",
"osm_response",
"[",
"'elements'",
"]",
":",
"if",
"'type'",
"in",
"result",
"and",
"result",
"[",
"'type'",
"]",
"==",
"'node'",
":",
"coords",
"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | parse_polygonal_poi | Parse areal POI way polygons from OSM node coords.
Parameters
----------
coords : dict
dict of node IDs and their lat, lon coordinates
Returns
-------
dict of POIs containing each's nodes, polygon geometry, and osmid | osmnx/pois.py | def parse_polygonal_poi(coords, response):
"""
Parse areal POI way polygons from OSM node coords.
Parameters
----------
coords : dict
dict of node IDs and their lat, lon coordinates
Returns
-------
dict of POIs containing each's nodes, polygon geometry, and osmid
"""
i... | def parse_polygonal_poi(coords, response):
"""
Parse areal POI way polygons from OSM node coords.
Parameters
----------
coords : dict
dict of node IDs and their lat, lon coordinates
Returns
-------
dict of POIs containing each's nodes, polygon geometry, and osmid
"""
i... | [
"Parse",
"areal",
"POI",
"way",
"polygons",
"from",
"OSM",
"node",
"coords",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L135-L166 | [
"def",
"parse_polygonal_poi",
"(",
"coords",
",",
"response",
")",
":",
"if",
"'type'",
"in",
"response",
"and",
"response",
"[",
"'type'",
"]",
"==",
"'way'",
":",
"nodes",
"=",
"response",
"[",
"'nodes'",
"]",
"try",
":",
"polygon",
"=",
"Polygon",
"("... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | parse_osm_node | Parse points from OSM nodes.
Parameters
----------
response : JSON
Nodes from OSM response.
Returns
-------
Dict of vertex IDs and their lat, lon coordinates. | osmnx/pois.py | def parse_osm_node(response):
"""
Parse points from OSM nodes.
Parameters
----------
response : JSON
Nodes from OSM response.
Returns
-------
Dict of vertex IDs and their lat, lon coordinates.
"""
try:
point = Point(response['lon'], response['lat'])
... | def parse_osm_node(response):
"""
Parse points from OSM nodes.
Parameters
----------
response : JSON
Nodes from OSM response.
Returns
-------
Dict of vertex IDs and their lat, lon coordinates.
"""
try:
point = Point(response['lon'], response['lat'])
... | [
"Parse",
"points",
"from",
"OSM",
"nodes",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L169-L197 | [
"def",
"parse_osm_node",
"(",
"response",
")",
":",
"try",
":",
"point",
"=",
"Point",
"(",
"response",
"[",
"'lon'",
"]",
",",
"response",
"[",
"'lat'",
"]",
")",
"poi",
"=",
"{",
"'osmid'",
":",
"response",
"[",
"'id'",
"]",
",",
"'geometry'",
":",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | invalid_multipoly_handler | Handles invalid multipolygon geometries when there exists e.g. a feature without
geometry (geometry == NaN)
Parameters
----------
gdf : gpd.GeoDataFrame
GeoDataFrame with Polygon geometries that should be converted into a MultiPolygon object.
relation : dict
OSM 'relation' diction... | osmnx/pois.py | def invalid_multipoly_handler(gdf, relation, way_ids):
"""
Handles invalid multipolygon geometries when there exists e.g. a feature without
geometry (geometry == NaN)
Parameters
----------
gdf : gpd.GeoDataFrame
GeoDataFrame with Polygon geometries that should be converted into a Mult... | def invalid_multipoly_handler(gdf, relation, way_ids):
"""
Handles invalid multipolygon geometries when there exists e.g. a feature without
geometry (geometry == NaN)
Parameters
----------
gdf : gpd.GeoDataFrame
GeoDataFrame with Polygon geometries that should be converted into a Mult... | [
"Handles",
"invalid",
"multipolygon",
"geometries",
"when",
"there",
"exists",
"e",
".",
"g",
".",
"a",
"feature",
"without",
"geometry",
"(",
"geometry",
"==",
"NaN",
")"
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L200-L224 | [
"def",
"invalid_multipoly_handler",
"(",
"gdf",
",",
"relation",
",",
"way_ids",
")",
":",
"try",
":",
"gdf_clean",
"=",
"gdf",
".",
"dropna",
"(",
"subset",
"=",
"[",
"'geometry'",
"]",
")",
"multipoly",
"=",
"MultiPolygon",
"(",
"list",
"(",
"gdf_clean",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | parse_osm_relations | Parses the osm relations (multipolygons) from osm
ways and nodes. See more information about relations
from OSM documentation: http://wiki.openstreetmap.org/wiki/Relation
Parameters
----------
relations : list
OSM 'relation' items (dictionaries) in a list.
osm_way_df : gpd.... | osmnx/pois.py | def parse_osm_relations(relations, osm_way_df):
"""
Parses the osm relations (multipolygons) from osm
ways and nodes. See more information about relations
from OSM documentation: http://wiki.openstreetmap.org/wiki/Relation
Parameters
----------
relations : list
OSM 'rela... | def parse_osm_relations(relations, osm_way_df):
"""
Parses the osm relations (multipolygons) from osm
ways and nodes. See more information about relations
from OSM documentation: http://wiki.openstreetmap.org/wiki/Relation
Parameters
----------
relations : list
OSM 'rela... | [
"Parses",
"the",
"osm",
"relations",
"(",
"multipolygons",
")",
"from",
"osm",
"ways",
"and",
"nodes",
".",
"See",
"more",
"information",
"about",
"relations",
"from",
"OSM",
"documentation",
":",
"http",
":",
"//",
"wiki",
".",
"openstreetmap",
".",
"org",
... | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L226-L286 | [
"def",
"parse_osm_relations",
"(",
"relations",
",",
"osm_way_df",
")",
":",
"gdf_relations",
"=",
"gpd",
".",
"GeoDataFrame",
"(",
")",
"# Iterate over relations and extract the items",
"for",
"relation",
"in",
"relations",
":",
"if",
"relation",
"[",
"'tags'",
"]"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | create_poi_gdf | Parse GeoDataFrames from POI json that was returned by Overpass API.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
geographic shape to fetch the POIs within
amenities: list
List of amenities that will be used for finding the POIs from the selected area.
See av... | osmnx/pois.py | def create_poi_gdf(polygon=None, amenities=None, north=None, south=None, east=None, west=None):
"""
Parse GeoDataFrames from POI json that was returned by Overpass API.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
geographic shape to fetch the POIs within
amenities: l... | def create_poi_gdf(polygon=None, amenities=None, north=None, south=None, east=None, west=None):
"""
Parse GeoDataFrames from POI json that was returned by Overpass API.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
geographic shape to fetch the POIs within
amenities: l... | [
"Parse",
"GeoDataFrames",
"from",
"POI",
"json",
"that",
"was",
"returned",
"by",
"Overpass",
"API",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L289-L361 | [
"def",
"create_poi_gdf",
"(",
"polygon",
"=",
"None",
",",
"amenities",
"=",
"None",
",",
"north",
"=",
"None",
",",
"south",
"=",
"None",
",",
"east",
"=",
"None",
",",
"west",
"=",
"None",
")",
":",
"responses",
"=",
"osm_poi_download",
"(",
"polygon... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | pois_from_point | Get point of interests (POIs) within some distance north, south, east, and west of
a lat-long point.
Parameters
----------
point : tuple
a lat-long point
distance : numeric
distance in meters
amenities : list
List of amenities that will be used for finding the POIs from ... | osmnx/pois.py | def pois_from_point(point, distance=None, amenities=None):
"""
Get point of interests (POIs) within some distance north, south, east, and west of
a lat-long point.
Parameters
----------
point : tuple
a lat-long point
distance : numeric
distance in meters
amenities : list... | def pois_from_point(point, distance=None, amenities=None):
"""
Get point of interests (POIs) within some distance north, south, east, and west of
a lat-long point.
Parameters
----------
point : tuple
a lat-long point
distance : numeric
distance in meters
amenities : list... | [
"Get",
"point",
"of",
"interests",
"(",
"POIs",
")",
"within",
"some",
"distance",
"north",
"south",
"east",
"and",
"west",
"of",
"a",
"lat",
"-",
"long",
"point",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L364-L386 | [
"def",
"pois_from_point",
"(",
"point",
",",
"distance",
"=",
"None",
",",
"amenities",
"=",
"None",
")",
":",
"bbox",
"=",
"bbox_from_point",
"(",
"point",
"=",
"point",
",",
"distance",
"=",
"distance",
")",
"north",
",",
"south",
",",
"east",
",",
"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | pois_from_address | Get OSM points of Interests within some distance north, south, east, and west of
an address.
Parameters
----------
address : string
the address to geocode to a lat-long point
distance : numeric
distance in meters
amenities : list
List of amenities that will be used for f... | osmnx/pois.py | def pois_from_address(address, distance, amenities=None):
"""
Get OSM points of Interests within some distance north, south, east, and west of
an address.
Parameters
----------
address : string
the address to geocode to a lat-long point
distance : numeric
distance in meters
... | def pois_from_address(address, distance, amenities=None):
"""
Get OSM points of Interests within some distance north, south, east, and west of
an address.
Parameters
----------
address : string
the address to geocode to a lat-long point
distance : numeric
distance in meters
... | [
"Get",
"OSM",
"points",
"of",
"Interests",
"within",
"some",
"distance",
"north",
"south",
"east",
"and",
"west",
"of",
"an",
"address",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L389-L413 | [
"def",
"pois_from_address",
"(",
"address",
",",
"distance",
",",
"amenities",
"=",
"None",
")",
":",
"# geocode the address string to a (lat, lon) point",
"point",
"=",
"geocode",
"(",
"query",
"=",
"address",
")",
"# get POIs within distance of this point",
"return",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | pois_from_place | Get points of interest (POIs) within the boundaries of some place.
Parameters
----------
place : string
the query to geocode to get geojson boundary polygon.
amenities : list
List of amenities that will be used for finding the POIs from the selected area.
See available amenities... | osmnx/pois.py | def pois_from_place(place, amenities=None):
"""
Get points of interest (POIs) within the boundaries of some place.
Parameters
----------
place : string
the query to geocode to get geojson boundary polygon.
amenities : list
List of amenities that will be used for finding the POIs... | def pois_from_place(place, amenities=None):
"""
Get points of interest (POIs) within the boundaries of some place.
Parameters
----------
place : string
the query to geocode to get geojson boundary polygon.
amenities : list
List of amenities that will be used for finding the POIs... | [
"Get",
"points",
"of",
"interest",
"(",
"POIs",
")",
"within",
"the",
"boundaries",
"of",
"some",
"place",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/pois.py#L436-L455 | [
"def",
"pois_from_place",
"(",
"place",
",",
"amenities",
"=",
"None",
")",
":",
"city",
"=",
"gdf_from_place",
"(",
"place",
")",
"polygon",
"=",
"city",
"[",
"'geometry'",
"]",
".",
"iloc",
"[",
"0",
"]",
"return",
"create_poi_gdf",
"(",
"polygon",
"="... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | is_endpoint | Return True if the node is a "real" endpoint of an edge in the network, \
otherwise False. OSM data includes lots of nodes that exist only as points \
to help streets bend around curves. An end point is a node that either: \
1) is its own neighbor, ie, it self-loops. \
2) or, has no incoming edges or no... | osmnx/simplify.py | def is_endpoint(G, node, strict=True):
"""
Return True if the node is a "real" endpoint of an edge in the network, \
otherwise False. OSM data includes lots of nodes that exist only as points \
to help streets bend around curves. An end point is a node that either: \
1) is its own neighbor, ie, it s... | def is_endpoint(G, node, strict=True):
"""
Return True if the node is a "real" endpoint of an edge in the network, \
otherwise False. OSM data includes lots of nodes that exist only as points \
to help streets bend around curves. An end point is a node that either: \
1) is its own neighbor, ie, it s... | [
"Return",
"True",
"if",
"the",
"node",
"is",
"a",
"real",
"endpoint",
"of",
"an",
"edge",
"in",
"the",
"network",
"\\",
"otherwise",
"False",
".",
"OSM",
"data",
"includes",
"lots",
"of",
"nodes",
"that",
"exist",
"only",
"as",
"points",
"\\",
"to",
"h... | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L20-L88 | [
"def",
"is_endpoint",
"(",
"G",
",",
"node",
",",
"strict",
"=",
"True",
")",
":",
"neighbors",
"=",
"set",
"(",
"list",
"(",
"G",
".",
"predecessors",
"(",
"node",
")",
")",
"+",
"list",
"(",
"G",
".",
"successors",
"(",
"node",
")",
")",
")",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | build_path | Recursively build a path of nodes until you hit an endpoint node.
Parameters
----------
G : networkx multidigraph
node : int
the current node to start from
endpoints : set
the set of all nodes in the graph that are endpoints
path : list
the list of nodes in order in the ... | osmnx/simplify.py | def build_path(G, node, endpoints, path):
"""
Recursively build a path of nodes until you hit an endpoint node.
Parameters
----------
G : networkx multidigraph
node : int
the current node to start from
endpoints : set
the set of all nodes in the graph that are endpoints
... | def build_path(G, node, endpoints, path):
"""
Recursively build a path of nodes until you hit an endpoint node.
Parameters
----------
G : networkx multidigraph
node : int
the current node to start from
endpoints : set
the set of all nodes in the graph that are endpoints
... | [
"Recursively",
"build",
"a",
"path",
"of",
"nodes",
"until",
"you",
"hit",
"an",
"endpoint",
"node",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L91-L131 | [
"def",
"build_path",
"(",
"G",
",",
"node",
",",
"endpoints",
",",
"path",
")",
":",
"# for each successor in the passed-in node",
"for",
"successor",
"in",
"G",
".",
"successors",
"(",
"node",
")",
":",
"if",
"successor",
"not",
"in",
"path",
":",
"# if thi... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_paths_to_simplify | Create a list of all the paths to be simplified between endpoint nodes.
The path is ordered from the first endpoint, through the interstitial nodes,
to the second endpoint. If your street network is in a rural area with many
interstitial nodes between true edge endpoints, you may want to increase
your ... | osmnx/simplify.py | def get_paths_to_simplify(G, strict=True):
"""
Create a list of all the paths to be simplified between endpoint nodes.
The path is ordered from the first endpoint, through the interstitial nodes,
to the second endpoint. If your street network is in a rural area with many
interstitial nodes between ... | def get_paths_to_simplify(G, strict=True):
"""
Create a list of all the paths to be simplified between endpoint nodes.
The path is ordered from the first endpoint, through the interstitial nodes,
to the second endpoint. If your street network is in a rural area with many
interstitial nodes between ... | [
"Create",
"a",
"list",
"of",
"all",
"the",
"paths",
"to",
"be",
"simplified",
"between",
"endpoint",
"nodes",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L134-L185 | [
"def",
"get_paths_to_simplify",
"(",
"G",
",",
"strict",
"=",
"True",
")",
":",
"# first identify all the nodes that are endpoints",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"endpoints",
"=",
"set",
"(",
"[",
"node",
"for",
"node",
"in",
"G",
".",
"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | simplify_graph | Simplify a graph's topology by removing all nodes that are not intersections
or dead-ends.
Create an edge directly between the end points that encapsulate them,
but retain the geometry of the original edges, saved as attribute in new
edge.
Parameters
----------
G : networkx multidigraph
... | osmnx/simplify.py | def simplify_graph(G, strict=True):
"""
Simplify a graph's topology by removing all nodes that are not intersections
or dead-ends.
Create an edge directly between the end points that encapsulate them,
but retain the geometry of the original edges, saved as attribute in new
edge.
Parameters... | def simplify_graph(G, strict=True):
"""
Simplify a graph's topology by removing all nodes that are not intersections
or dead-ends.
Create an edge directly between the end points that encapsulate them,
but retain the geometry of the original edges, saved as attribute in new
edge.
Parameters... | [
"Simplify",
"a",
"graph",
"s",
"topology",
"by",
"removing",
"all",
"nodes",
"that",
"are",
"not",
"intersections",
"or",
"dead",
"-",
"ends",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L207-L299 | [
"def",
"simplify_graph",
"(",
"G",
",",
"strict",
"=",
"True",
")",
":",
"if",
"is_simplified",
"(",
"G",
")",
":",
"raise",
"Exception",
"(",
"'This graph has already been simplified, cannot simplify it again.'",
")",
"log",
"(",
"'Begin topologically simplifying the g... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | clean_intersections | Clean-up intersections comprising clusters of nodes by merging them and
returning their centroids.
Divided roads are represented by separate centerline edges. The intersection
of two divided roads thus creates 4 nodes, representing where each edge
intersects a perpendicular edge. These 4 nodes represen... | osmnx/simplify.py | def clean_intersections(G, tolerance=15, dead_ends=False):
"""
Clean-up intersections comprising clusters of nodes by merging them and
returning their centroids.
Divided roads are represented by separate centerline edges. The intersection
of two divided roads thus creates 4 nodes, representing wher... | def clean_intersections(G, tolerance=15, dead_ends=False):
"""
Clean-up intersections comprising clusters of nodes by merging them and
returning their centroids.
Divided roads are represented by separate centerline edges. The intersection
of two divided roads thus creates 4 nodes, representing wher... | [
"Clean",
"-",
"up",
"intersections",
"comprising",
"clusters",
"of",
"nodes",
"by",
"merging",
"them",
"and",
"returning",
"their",
"centroids",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/simplify.py#L302-L357 | [
"def",
"clean_intersections",
"(",
"G",
",",
"tolerance",
"=",
"15",
",",
"dead_ends",
"=",
"False",
")",
":",
"# if dead_ends is False, discard dead-end nodes to only work with edge",
"# intersections",
"if",
"not",
"dead_ends",
":",
"if",
"'streets_per_node'",
"in",
"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | project_geometry | Project a shapely Polygon or MultiPolygon from lat-long to UTM, or
vice-versa
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to project
crs : dict
the starting coordinate reference system of the passed-in geometry,
default value (None) will set... | osmnx/projection.py | def project_geometry(geometry, crs=None, to_crs=None, to_latlong=False):
"""
Project a shapely Polygon or MultiPolygon from lat-long to UTM, or
vice-versa
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to project
crs : dict
the starting coordin... | def project_geometry(geometry, crs=None, to_crs=None, to_latlong=False):
"""
Project a shapely Polygon or MultiPolygon from lat-long to UTM, or
vice-versa
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to project
crs : dict
the starting coordin... | [
"Project",
"a",
"shapely",
"Polygon",
"or",
"MultiPolygon",
"from",
"lat",
"-",
"long",
"to",
"UTM",
"or",
"vice",
"-",
"versa"
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/projection.py#L20-L55 | [
"def",
"project_geometry",
"(",
"geometry",
",",
"crs",
"=",
"None",
",",
"to_crs",
"=",
"None",
",",
"to_latlong",
"=",
"False",
")",
":",
"if",
"crs",
"is",
"None",
":",
"crs",
"=",
"settings",
".",
"default_crs",
"gdf",
"=",
"gpd",
".",
"GeoDataFram... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | project_gdf | Project a GeoDataFrame to the UTM zone appropriate for its geometries'
centroid.
The simple calculation in this function works well for most latitudes, but
won't work for some far northern locations like Svalbard and parts of far
northern Norway.
Parameters
----------
gdf : GeoDataFrame
... | osmnx/projection.py | def project_gdf(gdf, to_crs=None, to_latlong=False):
"""
Project a GeoDataFrame to the UTM zone appropriate for its geometries'
centroid.
The simple calculation in this function works well for most latitudes, but
won't work for some far northern locations like Svalbard and parts of far
northern... | def project_gdf(gdf, to_crs=None, to_latlong=False):
"""
Project a GeoDataFrame to the UTM zone appropriate for its geometries'
centroid.
The simple calculation in this function works well for most latitudes, but
won't work for some far northern locations like Svalbard and parts of far
northern... | [
"Project",
"a",
"GeoDataFrame",
"to",
"the",
"UTM",
"zone",
"appropriate",
"for",
"its",
"geometries",
"centroid",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/projection.py#L58-L123 | [
"def",
"project_gdf",
"(",
"gdf",
",",
"to_crs",
"=",
"None",
",",
"to_latlong",
"=",
"False",
")",
":",
"assert",
"len",
"(",
"gdf",
")",
">",
"0",
",",
"'You cannot project an empty GeoDataFrame.'",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"# if... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | project_graph | Project a graph from lat-long to the UTM zone appropriate for its geographic
location.
Parameters
----------
G : networkx multidigraph
the networkx graph to be projected
to_crs : dict
if not None, just project to this CRS instead of to UTM
Returns
-------
networkx multi... | osmnx/projection.py | def project_graph(G, to_crs=None):
"""
Project a graph from lat-long to the UTM zone appropriate for its geographic
location.
Parameters
----------
G : networkx multidigraph
the networkx graph to be projected
to_crs : dict
if not None, just project to this CRS instead of to ... | def project_graph(G, to_crs=None):
"""
Project a graph from lat-long to the UTM zone appropriate for its geographic
location.
Parameters
----------
G : networkx multidigraph
the networkx graph to be projected
to_crs : dict
if not None, just project to this CRS instead of to ... | [
"Project",
"a",
"graph",
"from",
"lat",
"-",
"long",
"to",
"the",
"UTM",
"zone",
"appropriate",
"for",
"its",
"geographic",
"location",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/projection.py#L126-L214 | [
"def",
"project_graph",
"(",
"G",
",",
"to_crs",
"=",
"None",
")",
":",
"G_proj",
"=",
"G",
".",
"copy",
"(",
")",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"# create a GeoDataFrame of the nodes, name it, convert osmid to str",
"nodes",
",",
"data",
"=... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | plot_shape | Plot a GeoDataFrame of place boundary geometries.
Parameters
----------
gdf : GeoDataFrame
the gdf containing the geometries to plot
fc : string or list
the facecolor (or list of facecolors) for the polygons
ec : string or list
the edgecolor (or list of edgecolors) for the p... | osmnx/plot.py | def plot_shape(gdf, fc='#cbe0f0', ec='#999999', linewidth=1, alpha=1,
figsize=(6,6), margin=0.02, axis_off=True):
"""
Plot a GeoDataFrame of place boundary geometries.
Parameters
----------
gdf : GeoDataFrame
the gdf containing the geometries to plot
fc : string or list
... | def plot_shape(gdf, fc='#cbe0f0', ec='#999999', linewidth=1, alpha=1,
figsize=(6,6), margin=0.02, axis_off=True):
"""
Plot a GeoDataFrame of place boundary geometries.
Parameters
----------
gdf : GeoDataFrame
the gdf containing the geometries to plot
fc : string or list
... | [
"Plot",
"a",
"GeoDataFrame",
"of",
"place",
"boundary",
"geometries",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L37-L97 | [
"def",
"plot_shape",
"(",
"gdf",
",",
"fc",
"=",
"'#cbe0f0'",
",",
"ec",
"=",
"'#999999'",
",",
"linewidth",
"=",
"1",
",",
"alpha",
"=",
"1",
",",
"figsize",
"=",
"(",
"6",
",",
"6",
")",
",",
"margin",
"=",
"0.02",
",",
"axis_off",
"=",
"True",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | rgb_color_list_to_hex | Convert a list of RGBa colors to a list of hexadecimal color codes.
Parameters
----------
color_list : list
the list of RGBa colors
Returns
-------
color_list_hex : list | osmnx/plot.py | def rgb_color_list_to_hex(color_list):
"""
Convert a list of RGBa colors to a list of hexadecimal color codes.
Parameters
----------
color_list : list
the list of RGBa colors
Returns
-------
color_list_hex : list
"""
color_list_rgb = [[int(x*255) for x in c[0:3]] for c ... | def rgb_color_list_to_hex(color_list):
"""
Convert a list of RGBa colors to a list of hexadecimal color codes.
Parameters
----------
color_list : list
the list of RGBa colors
Returns
-------
color_list_hex : list
"""
color_list_rgb = [[int(x*255) for x in c[0:3]] for c ... | [
"Convert",
"a",
"list",
"of",
"RGBa",
"colors",
"to",
"a",
"list",
"of",
"hexadecimal",
"color",
"codes",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L100-L115 | [
"def",
"rgb_color_list_to_hex",
"(",
"color_list",
")",
":",
"color_list_rgb",
"=",
"[",
"[",
"int",
"(",
"x",
"*",
"255",
")",
"for",
"x",
"in",
"c",
"[",
"0",
":",
"3",
"]",
"]",
"for",
"c",
"in",
"color_list",
"]",
"color_list_hex",
"=",
"[",
"'... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_colors | Return n-length list of RGBa colors from the passed colormap name and alpha.
Parameters
----------
n : int
number of colors
cmap : string
name of a colormap
start : float
where to start in the colorspace
stop : float
where to end in the colorspace
alpha : flo... | osmnx/plot.py | def get_colors(n, cmap='viridis', start=0., stop=1., alpha=1., return_hex=False):
"""
Return n-length list of RGBa colors from the passed colormap name and alpha.
Parameters
----------
n : int
number of colors
cmap : string
name of a colormap
start : float
where to s... | def get_colors(n, cmap='viridis', start=0., stop=1., alpha=1., return_hex=False):
"""
Return n-length list of RGBa colors from the passed colormap name and alpha.
Parameters
----------
n : int
number of colors
cmap : string
name of a colormap
start : float
where to s... | [
"Return",
"n",
"-",
"length",
"list",
"of",
"RGBa",
"colors",
"from",
"the",
"passed",
"colormap",
"name",
"and",
"alpha",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L118-L145 | [
"def",
"get_colors",
"(",
"n",
",",
"cmap",
"=",
"'viridis'",
",",
"start",
"=",
"0.",
",",
"stop",
"=",
"1.",
",",
"alpha",
"=",
"1.",
",",
"return_hex",
"=",
"False",
")",
":",
"colors",
"=",
"[",
"cm",
".",
"get_cmap",
"(",
"cmap",
")",
"(",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_node_colors_by_attr | Get a list of node colors by binning some continuous-variable attribute into
quantiles.
Parameters
----------
G : networkx multidigraph
attr : string
the name of the attribute
num_bins : int
how many quantiles (default None assigns each node to its own bin)
cmap : string
... | osmnx/plot.py | def get_node_colors_by_attr(G, attr, num_bins=None, cmap='viridis', start=0, stop=1, na_color='none'):
"""
Get a list of node colors by binning some continuous-variable attribute into
quantiles.
Parameters
----------
G : networkx multidigraph
attr : string
the name of the attribute
... | def get_node_colors_by_attr(G, attr, num_bins=None, cmap='viridis', start=0, stop=1, na_color='none'):
"""
Get a list of node colors by binning some continuous-variable attribute into
quantiles.
Parameters
----------
G : networkx multidigraph
attr : string
the name of the attribute
... | [
"Get",
"a",
"list",
"of",
"node",
"colors",
"by",
"binning",
"some",
"continuous",
"-",
"variable",
"attribute",
"into",
"quantiles",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L148-L180 | [
"def",
"get_node_colors_by_attr",
"(",
"G",
",",
"attr",
",",
"num_bins",
"=",
"None",
",",
"cmap",
"=",
"'viridis'",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"1",
",",
"na_color",
"=",
"'none'",
")",
":",
"if",
"num_bins",
"is",
"None",
":",
"num_b... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_edge_colors_by_attr | Get a list of edge colors by binning some continuous-variable attribute into
quantiles.
Parameters
----------
G : networkx multidigraph
attr : string
the name of the continuous-variable attribute
num_bins : int
how many quantiles
cmap : string
name of a colormap
... | osmnx/plot.py | def get_edge_colors_by_attr(G, attr, num_bins=5, cmap='viridis', start=0, stop=1, na_color='none'):
"""
Get a list of edge colors by binning some continuous-variable attribute into
quantiles.
Parameters
----------
G : networkx multidigraph
attr : string
the name of the continuous-va... | def get_edge_colors_by_attr(G, attr, num_bins=5, cmap='viridis', start=0, stop=1, na_color='none'):
"""
Get a list of edge colors by binning some continuous-variable attribute into
quantiles.
Parameters
----------
G : networkx multidigraph
attr : string
the name of the continuous-va... | [
"Get",
"a",
"list",
"of",
"edge",
"colors",
"by",
"binning",
"some",
"continuous",
"-",
"variable",
"attribute",
"into",
"quantiles",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L183-L215 | [
"def",
"get_edge_colors_by_attr",
"(",
"G",
",",
"attr",
",",
"num_bins",
"=",
"5",
",",
"cmap",
"=",
"'viridis'",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"1",
",",
"na_color",
"=",
"'none'",
")",
":",
"if",
"num_bins",
"is",
"None",
":",
"num_bins... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | save_and_show | Save a figure to disk and show it, as specified.
Parameters
----------
fig : figure
ax : axis
save : bool
whether to save the figure to disk or not
show : bool
whether to display the figure or not
close : bool
close the figure (only if show equals False) to prevent d... | osmnx/plot.py | def save_and_show(fig, ax, save, show, close, filename, file_format, dpi, axis_off):
"""
Save a figure to disk and show it, as specified.
Parameters
----------
fig : figure
ax : axis
save : bool
whether to save the figure to disk or not
show : bool
whether to display the... | def save_and_show(fig, ax, save, show, close, filename, file_format, dpi, axis_off):
"""
Save a figure to disk and show it, as specified.
Parameters
----------
fig : figure
ax : axis
save : bool
whether to save the figure to disk or not
show : bool
whether to display the... | [
"Save",
"a",
"figure",
"to",
"disk",
"and",
"show",
"it",
"as",
"specified",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L218-L281 | [
"def",
"save_and_show",
"(",
"fig",
",",
"ax",
",",
"save",
",",
"show",
",",
"close",
",",
"filename",
",",
"file_format",
",",
"dpi",
",",
"axis_off",
")",
":",
"# save the figure if specified",
"if",
"save",
":",
"start_time",
"=",
"time",
".",
"time",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | plot_graph | Plot a networkx spatial graph.
Parameters
----------
G : networkx multidigraph
bbox : tuple
bounding box as north,south,east,west - if None will calculate from
spatial extents of data. if passing a bbox, you probably also want to
pass margin=0 to constrain it.
fig_height : i... | osmnx/plot.py | def plot_graph(G, bbox=None, fig_height=6, fig_width=None, margin=0.02,
axis_off=True, equal_aspect=False, bgcolor='w', show=True,
save=False, close=True, file_format='png', filename='temp',
dpi=300, annotate=False, node_color='#66ccff', node_size=15,
node_alp... | def plot_graph(G, bbox=None, fig_height=6, fig_width=None, margin=0.02,
axis_off=True, equal_aspect=False, bgcolor='w', show=True,
save=False, close=True, file_format='png', filename='temp',
dpi=300, annotate=False, node_color='#66ccff', node_size=15,
node_alp... | [
"Plot",
"a",
"networkx",
"spatial",
"graph",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L284-L444 | [
"def",
"plot_graph",
"(",
"G",
",",
"bbox",
"=",
"None",
",",
"fig_height",
"=",
"6",
",",
"fig_width",
"=",
"None",
",",
"margin",
"=",
"0.02",
",",
"axis_off",
"=",
"True",
",",
"equal_aspect",
"=",
"False",
",",
"bgcolor",
"=",
"'w'",
",",
"show",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | node_list_to_coordinate_lines | Given a list of nodes, return a list of lines that together follow the path
defined by the list of nodes.
Parameters
----------
G : networkx multidigraph
route : list
the route as a list of nodes
use_geom : bool
if True, use the spatial geometry attribute of the edges to draw
... | osmnx/plot.py | def node_list_to_coordinate_lines(G, node_list, use_geom=True):
"""
Given a list of nodes, return a list of lines that together follow the path
defined by the list of nodes.
Parameters
----------
G : networkx multidigraph
route : list
the route as a list of nodes
use_geom : bool... | def node_list_to_coordinate_lines(G, node_list, use_geom=True):
"""
Given a list of nodes, return a list of lines that together follow the path
defined by the list of nodes.
Parameters
----------
G : networkx multidigraph
route : list
the route as a list of nodes
use_geom : bool... | [
"Given",
"a",
"list",
"of",
"nodes",
"return",
"a",
"list",
"of",
"lines",
"that",
"together",
"follow",
"the",
"path",
"defined",
"by",
"the",
"list",
"of",
"nodes",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L447-L486 | [
"def",
"node_list_to_coordinate_lines",
"(",
"G",
",",
"node_list",
",",
"use_geom",
"=",
"True",
")",
":",
"edge_nodes",
"=",
"list",
"(",
"zip",
"(",
"node_list",
"[",
":",
"-",
"1",
"]",
",",
"node_list",
"[",
"1",
":",
"]",
")",
")",
"lines",
"="... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | plot_graph_route | Plot a route along a networkx spatial graph.
Parameters
----------
G : networkx multidigraph
route : list
the route as a list of nodes
bbox : tuple
bounding box as north,south,east,west - if None will calculate from
spatial extents of data. if passing a bbox, you probably al... | osmnx/plot.py | def plot_graph_route(G, route, bbox=None, fig_height=6, fig_width=None,
margin=0.02, bgcolor='w', axis_off=True, show=True,
save=False, close=True, file_format='png', filename='temp',
dpi=300, annotate=False, node_color='#999999',
node_... | def plot_graph_route(G, route, bbox=None, fig_height=6, fig_width=None,
margin=0.02, bgcolor='w', axis_off=True, show=True,
save=False, close=True, file_format='png', filename='temp',
dpi=300, annotate=False, node_color='#999999',
node_... | [
"Plot",
"a",
"route",
"along",
"a",
"networkx",
"spatial",
"graph",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L488-L620 | [
"def",
"plot_graph_route",
"(",
"G",
",",
"route",
",",
"bbox",
"=",
"None",
",",
"fig_height",
"=",
"6",
",",
"fig_width",
"=",
"None",
",",
"margin",
"=",
"0.02",
",",
"bgcolor",
"=",
"'w'",
",",
"axis_off",
"=",
"True",
",",
"show",
"=",
"True",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | make_folium_polyline | Turn a row from the gdf_edges GeoDataFrame into a folium PolyLine with
attributes.
Parameters
----------
edge : GeoSeries
a row from the gdf_edges GeoDataFrame
edge_color : string
color of the edge lines
edge_width : numeric
width of the edge lines
edge_opacity : num... | osmnx/plot.py | def make_folium_polyline(edge, edge_color, edge_width, edge_opacity, popup_attribute=None):
"""
Turn a row from the gdf_edges GeoDataFrame into a folium PolyLine with
attributes.
Parameters
----------
edge : GeoSeries
a row from the gdf_edges GeoDataFrame
edge_color : string
... | def make_folium_polyline(edge, edge_color, edge_width, edge_opacity, popup_attribute=None):
"""
Turn a row from the gdf_edges GeoDataFrame into a folium PolyLine with
attributes.
Parameters
----------
edge : GeoSeries
a row from the gdf_edges GeoDataFrame
edge_color : string
... | [
"Turn",
"a",
"row",
"from",
"the",
"gdf_edges",
"GeoDataFrame",
"into",
"a",
"folium",
"PolyLine",
"with",
"attributes",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L763-L809 | [
"def",
"make_folium_polyline",
"(",
"edge",
",",
"edge_color",
",",
"edge_width",
",",
"edge_opacity",
",",
"popup_attribute",
"=",
"None",
")",
":",
"# check if we were able to import folium successfully",
"if",
"not",
"folium",
":",
"raise",
"ImportError",
"(",
"'Th... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | plot_graph_folium | Plot a graph on an interactive folium web map.
Note that anything larger than a small city can take a long time to plot and
create a large web map file that is very slow to load as JavaScript.
Parameters
----------
G : networkx multidigraph
graph_map : folium.folium.Map
if not None, pl... | osmnx/plot.py | def plot_graph_folium(G, graph_map=None, popup_attribute=None,
tiles='cartodbpositron', zoom=1, fit_bounds=True,
edge_color='#333333', edge_width=5, edge_opacity=1):
"""
Plot a graph on an interactive folium web map.
Note that anything larger than a small city ca... | def plot_graph_folium(G, graph_map=None, popup_attribute=None,
tiles='cartodbpositron', zoom=1, fit_bounds=True,
edge_color='#333333', edge_width=5, edge_opacity=1):
"""
Plot a graph on an interactive folium web map.
Note that anything larger than a small city ca... | [
"Plot",
"a",
"graph",
"on",
"an",
"interactive",
"folium",
"web",
"map",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L812-L874 | [
"def",
"plot_graph_folium",
"(",
"G",
",",
"graph_map",
"=",
"None",
",",
"popup_attribute",
"=",
"None",
",",
"tiles",
"=",
"'cartodbpositron'",
",",
"zoom",
"=",
"1",
",",
"fit_bounds",
"=",
"True",
",",
"edge_color",
"=",
"'#333333'",
",",
"edge_width",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | plot_route_folium | Plot a route on an interactive folium web map.
Parameters
----------
G : networkx multidigraph
route : list
the route as a list of nodes
route_map : folium.folium.Map
if not None, plot the route on this preexisting folium map object
popup_attribute : string
edge attribut... | osmnx/plot.py | def plot_route_folium(G, route, route_map=None, popup_attribute=None,
tiles='cartodbpositron', zoom=1, fit_bounds=True,
route_color='#cc0000', route_width=5, route_opacity=1):
"""
Plot a route on an interactive folium web map.
Parameters
----------
G : ne... | def plot_route_folium(G, route, route_map=None, popup_attribute=None,
tiles='cartodbpositron', zoom=1, fit_bounds=True,
route_color='#cc0000', route_width=5, route_opacity=1):
"""
Plot a route on an interactive folium web map.
Parameters
----------
G : ne... | [
"Plot",
"a",
"route",
"on",
"an",
"interactive",
"folium",
"web",
"map",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L877-L941 | [
"def",
"plot_route_folium",
"(",
"G",
",",
"route",
",",
"route_map",
"=",
"None",
",",
"popup_attribute",
"=",
"None",
",",
"tiles",
"=",
"'cartodbpositron'",
",",
"zoom",
"=",
"1",
",",
"fit_bounds",
"=",
"True",
",",
"route_color",
"=",
"'#cc0000'",
","... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | plot_figure_ground | Plot a figure-ground diagram of a street network, defaulting to one square
mile.
Parameters
----------
G : networkx multidigraph
address : string
the address to geocode as the center point if G is not passed in
point : tuple
the center point if address and G are not passed in
... | osmnx/plot.py | def plot_figure_ground(G=None, address=None, point=None, dist=805,
network_type='drive_service', street_widths=None,
default_width=4, fig_length=8, edge_color='w',
bgcolor='#333333', smooth_joints=True, filename=None,
file_forma... | def plot_figure_ground(G=None, address=None, point=None, dist=805,
network_type='drive_service', street_widths=None,
default_width=4, fig_length=8, edge_color='w',
bgcolor='#333333', smooth_joints=True, filename=None,
file_forma... | [
"Plot",
"a",
"figure",
"-",
"ground",
"diagram",
"of",
"a",
"street",
"network",
"defaulting",
"to",
"one",
"square",
"mile",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/plot.py#L944-L1100 | [
"def",
"plot_figure_ground",
"(",
"G",
"=",
"None",
",",
"address",
"=",
"None",
",",
"point",
"=",
"None",
",",
"dist",
"=",
"805",
",",
"network_type",
"=",
"'drive_service'",
",",
"street_widths",
"=",
"None",
",",
"default_width",
"=",
"4",
",",
"fig... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | save_to_cache | Save an HTTP response json object to the cache.
If the request was sent to server via POST instead of GET, then URL should
be a GET-style representation of request. Users should always pass
OrderedDicts instead of dicts of parameters into request functions, so that
the parameters stay in the same order... | osmnx/core.py | def save_to_cache(url, response_json):
"""
Save an HTTP response json object to the cache.
If the request was sent to server via POST instead of GET, then URL should
be a GET-style representation of request. Users should always pass
OrderedDicts instead of dicts of parameters into request functions... | def save_to_cache(url, response_json):
"""
Save an HTTP response json object to the cache.
If the request was sent to server via POST instead of GET, then URL should
be a GET-style representation of request. Users should always pass
OrderedDicts instead of dicts of parameters into request functions... | [
"Save",
"an",
"HTTP",
"response",
"json",
"object",
"to",
"the",
"cache",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L67-L108 | [
"def",
"save_to_cache",
"(",
"url",
",",
"response_json",
")",
":",
"if",
"settings",
".",
"use_cache",
":",
"if",
"response_json",
"is",
"None",
":",
"log",
"(",
"'Saved nothing to cache because response_json is None'",
")",
"else",
":",
"# create the folder on the d... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_from_cache | Retrieve a HTTP response json object from the cache.
Parameters
----------
url : string
the url of the request
Returns
-------
response_json : dict | osmnx/core.py | def get_from_cache(url):
"""
Retrieve a HTTP response json object from the cache.
Parameters
----------
url : string
the url of the request
Returns
-------
response_json : dict
"""
# if the tool is configured to use the cache
if settings.use_cache:
# determi... | def get_from_cache(url):
"""
Retrieve a HTTP response json object from the cache.
Parameters
----------
url : string
the url of the request
Returns
-------
response_json : dict
"""
# if the tool is configured to use the cache
if settings.use_cache:
# determi... | [
"Retrieve",
"a",
"HTTP",
"response",
"json",
"object",
"from",
"the",
"cache",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L111-L136 | [
"def",
"get_from_cache",
"(",
"url",
")",
":",
"# if the tool is configured to use the cache",
"if",
"settings",
".",
"use_cache",
":",
"# determine the filename by hashing the url",
"filename",
"=",
"hashlib",
".",
"md5",
"(",
"url",
".",
"encode",
"(",
"'utf-8'",
")... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_http_headers | Update the default requests HTTP headers with OSMnx info.
Parameters
----------
user_agent : str
the user agent string, if None will set with OSMnx default
referer : str
the referer string, if None will set with OSMnx default
accept_language : str
make accept-language explic... | osmnx/core.py | def get_http_headers(user_agent=None, referer=None, accept_language=None):
"""
Update the default requests HTTP headers with OSMnx info.
Parameters
----------
user_agent : str
the user agent string, if None will set with OSMnx default
referer : str
the referer string, if None wi... | def get_http_headers(user_agent=None, referer=None, accept_language=None):
"""
Update the default requests HTTP headers with OSMnx info.
Parameters
----------
user_agent : str
the user agent string, if None will set with OSMnx default
referer : str
the referer string, if None wi... | [
"Update",
"the",
"default",
"requests",
"HTTP",
"headers",
"with",
"OSMnx",
"info",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L139-L166 | [
"def",
"get_http_headers",
"(",
"user_agent",
"=",
"None",
",",
"referer",
"=",
"None",
",",
"accept_language",
"=",
"None",
")",
":",
"if",
"user_agent",
"is",
"None",
":",
"user_agent",
"=",
"settings",
".",
"default_user_agent",
"if",
"referer",
"is",
"No... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | nominatim_request | Send a request to the Nominatim API via HTTP GET and return the JSON
response.
Parameters
----------
params : dict or OrderedDict
key-value pairs of parameters
type : string
Type of Nominatim query. One of the following: search, reverse or lookup
pause_duration : int
how... | osmnx/core.py | def nominatim_request(params, type = "search", pause_duration=1, timeout=30, error_pause_duration=180):
"""
Send a request to the Nominatim API via HTTP GET and return the JSON
response.
Parameters
----------
params : dict or OrderedDict
key-value pairs of parameters
type : string
... | def nominatim_request(params, type = "search", pause_duration=1, timeout=30, error_pause_duration=180):
"""
Send a request to the Nominatim API via HTTP GET and return the JSON
response.
Parameters
----------
params : dict or OrderedDict
key-value pairs of parameters
type : string
... | [
"Send",
"a",
"request",
"to",
"the",
"Nominatim",
"API",
"via",
"HTTP",
"GET",
"and",
"return",
"the",
"JSON",
"response",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L224-L296 | [
"def",
"nominatim_request",
"(",
"params",
",",
"type",
"=",
"\"search\"",
",",
"pause_duration",
"=",
"1",
",",
"timeout",
"=",
"30",
",",
"error_pause_duration",
"=",
"180",
")",
":",
"known_requests",
"=",
"{",
"\"search\"",
",",
"\"reverse\"",
",",
"\"lo... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | overpass_request | Send a request to the Overpass API via HTTP POST and return the JSON
response.
Parameters
----------
data : dict or OrderedDict
key-value pairs of parameters to post to the API
pause_duration : int
how long to pause in seconds before requests, if None, will query API
status ... | osmnx/core.py | def overpass_request(data, pause_duration=None, timeout=180, error_pause_duration=None):
"""
Send a request to the Overpass API via HTTP POST and return the JSON
response.
Parameters
----------
data : dict or OrderedDict
key-value pairs of parameters to post to the API
pause_duratio... | def overpass_request(data, pause_duration=None, timeout=180, error_pause_duration=None):
"""
Send a request to the Overpass API via HTTP POST and return the JSON
response.
Parameters
----------
data : dict or OrderedDict
key-value pairs of parameters to post to the API
pause_duratio... | [
"Send",
"a",
"request",
"to",
"the",
"Overpass",
"API",
"via",
"HTTP",
"POST",
"and",
"return",
"the",
"JSON",
"response",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L299-L372 | [
"def",
"overpass_request",
"(",
"data",
",",
"pause_duration",
"=",
"None",
",",
"timeout",
"=",
"180",
",",
"error_pause_duration",
"=",
"None",
")",
":",
"# define the Overpass API URL, then construct a GET-style URL as a string to",
"# hash to look up/save to cache",
"url"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | osm_polygon_download | Geocode a place and download its boundary geometry from OSM's Nominatim API.
Parameters
----------
query : string or dict
query string or structured query dict to geocode/download
limit : int
max number of results to return
polygon_geojson : int
request the boundary geometry... | osmnx/core.py | def osm_polygon_download(query, limit=1, polygon_geojson=1):
"""
Geocode a place and download its boundary geometry from OSM's Nominatim API.
Parameters
----------
query : string or dict
query string or structured query dict to geocode/download
limit : int
max number of results ... | def osm_polygon_download(query, limit=1, polygon_geojson=1):
"""
Geocode a place and download its boundary geometry from OSM's Nominatim API.
Parameters
----------
query : string or dict
query string or structured query dict to geocode/download
limit : int
max number of results ... | [
"Geocode",
"a",
"place",
"and",
"download",
"its",
"boundary",
"geometry",
"from",
"OSM",
"s",
"Nominatim",
"API",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L375-L413 | [
"def",
"osm_polygon_download",
"(",
"query",
",",
"limit",
"=",
"1",
",",
"polygon_geojson",
"=",
"1",
")",
":",
"# define the parameters",
"params",
"=",
"OrderedDict",
"(",
")",
"params",
"[",
"'format'",
"]",
"=",
"'json'",
"params",
"[",
"'limit'",
"]",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | gdf_from_place | Create a GeoDataFrame from a single place name query.
Parameters
----------
query : string or dict
query string or structured query dict to geocode/download
gdf_name : string
name attribute metadata for GeoDataFrame (this is used to save shapefile
later)
which_result : int
... | osmnx/core.py | def gdf_from_place(query, gdf_name=None, which_result=1, buffer_dist=None):
"""
Create a GeoDataFrame from a single place name query.
Parameters
----------
query : string or dict
query string or structured query dict to geocode/download
gdf_name : string
name attribute metadata ... | def gdf_from_place(query, gdf_name=None, which_result=1, buffer_dist=None):
"""
Create a GeoDataFrame from a single place name query.
Parameters
----------
query : string or dict
query string or structured query dict to geocode/download
gdf_name : string
name attribute metadata ... | [
"Create",
"a",
"GeoDataFrame",
"from",
"a",
"single",
"place",
"name",
"query",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L416-L486 | [
"def",
"gdf_from_place",
"(",
"query",
",",
"gdf_name",
"=",
"None",
",",
"which_result",
"=",
"1",
",",
"buffer_dist",
"=",
"None",
")",
":",
"# if no gdf_name is passed, just use the query",
"assert",
"(",
"isinstance",
"(",
"query",
",",
"dict",
")",
"or",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | gdf_from_places | Create a GeoDataFrame from a list of place names to query.
Parameters
----------
queries : list
list of query strings or structured query dicts to geocode/download, one
at a time
gdf_name : string
name attribute metadata for GeoDataFrame (this is used to save shapefile
l... | osmnx/core.py | def gdf_from_places(queries, gdf_name='unnamed', buffer_dist=None):
"""
Create a GeoDataFrame from a list of place names to query.
Parameters
----------
queries : list
list of query strings or structured query dicts to geocode/download, one
at a time
gdf_name : string
na... | def gdf_from_places(queries, gdf_name='unnamed', buffer_dist=None):
"""
Create a GeoDataFrame from a list of place names to query.
Parameters
----------
queries : list
list of query strings or structured query dicts to geocode/download, one
at a time
gdf_name : string
na... | [
"Create",
"a",
"GeoDataFrame",
"from",
"a",
"list",
"of",
"place",
"names",
"to",
"query",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L489-L520 | [
"def",
"gdf_from_places",
"(",
"queries",
",",
"gdf_name",
"=",
"'unnamed'",
",",
"buffer_dist",
"=",
"None",
")",
":",
"# create an empty GeoDataFrame then append each result as a new row",
"gdf",
"=",
"gpd",
".",
"GeoDataFrame",
"(",
")",
"for",
"query",
"in",
"qu... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_osm_filter | Create a filter to query OSM for the specified network type.
Parameters
----------
network_type : string
{'walk', 'bike', 'drive', 'drive_service', 'all', 'all_private', 'none'}
what type of street or other network to get
Returns
-------
string | osmnx/core.py | def get_osm_filter(network_type):
"""
Create a filter to query OSM for the specified network type.
Parameters
----------
network_type : string
{'walk', 'bike', 'drive', 'drive_service', 'all', 'all_private', 'none'}
what type of street or other network to get
Returns
------... | def get_osm_filter(network_type):
"""
Create a filter to query OSM for the specified network type.
Parameters
----------
network_type : string
{'walk', 'bike', 'drive', 'drive_service', 'all', 'all_private', 'none'}
what type of street or other network to get
Returns
------... | [
"Create",
"a",
"filter",
"to",
"query",
"OSM",
"for",
"the",
"specified",
"network",
"type",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L523-L585 | [
"def",
"get_osm_filter",
"(",
"network_type",
")",
":",
"filters",
"=",
"{",
"}",
"# driving: filter out un-drivable roads, service roads, private ways, and",
"# anything specifying motor=no. also filter out any non-service roads that",
"# are tagged as providing parking, driveway, private, ... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | osm_net_download | Download OSM ways and nodes within some bounding box from the Overpass API.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
geographic shape to fetch the street network within
north : float
northern latitude of bounding box
south : float
southern latitude of ... | osmnx/core.py | def osm_net_download(polygon=None, north=None, south=None, east=None, west=None,
network_type='all_private', timeout=180, memory=None,
max_query_area_size=50*1000*50*1000, infrastructure='way["highway"]',
custom_filter=None):
"""
Download OSM ways a... | def osm_net_download(polygon=None, north=None, south=None, east=None, west=None,
network_type='all_private', timeout=180, memory=None,
max_query_area_size=50*1000*50*1000, infrastructure='way["highway"]',
custom_filter=None):
"""
Download OSM ways a... | [
"Download",
"OSM",
"ways",
"and",
"nodes",
"within",
"some",
"bounding",
"box",
"from",
"the",
"Overpass",
"API",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L588-L710 | [
"def",
"osm_net_download",
"(",
"polygon",
"=",
"None",
",",
"north",
"=",
"None",
",",
"south",
"=",
"None",
",",
"east",
"=",
"None",
",",
"west",
"=",
"None",
",",
"network_type",
"=",
"'all_private'",
",",
"timeout",
"=",
"180",
",",
"memory",
"=",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_polygons_coordinates | Extract exterior coordinates from polygon(s) to pass to OSM in a query by
polygon. Ignore the interior ("holes") coordinates.
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to extract exterior coordinates from
Returns
-------
polygon_coord_strs : list | osmnx/core.py | def get_polygons_coordinates(geometry):
"""
Extract exterior coordinates from polygon(s) to pass to OSM in a query by
polygon. Ignore the interior ("holes") coordinates.
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to extract exterior coordinates from
... | def get_polygons_coordinates(geometry):
"""
Extract exterior coordinates from polygon(s) to pass to OSM in a query by
polygon. Ignore the interior ("holes") coordinates.
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to extract exterior coordinates from
... | [
"Extract",
"exterior",
"coordinates",
"from",
"polygon",
"(",
"s",
")",
"to",
"pass",
"to",
"OSM",
"in",
"a",
"query",
"by",
"polygon",
".",
"Ignore",
"the",
"interior",
"(",
"holes",
")",
"coordinates",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L753-L792 | [
"def",
"get_polygons_coordinates",
"(",
"geometry",
")",
":",
"# extract the exterior coordinates of the geometry to pass to the API later",
"polygons_coords",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"geometry",
",",
"Polygon",
")",
":",
"x",
",",
"y",
"=",
"geometry",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_node | Convert an OSM node element into the format for a networkx node.
Parameters
----------
element : dict
an OSM node element
Returns
-------
dict | osmnx/core.py | def get_node(element):
"""
Convert an OSM node element into the format for a networkx node.
Parameters
----------
element : dict
an OSM node element
Returns
-------
dict
"""
node = {}
node['y'] = element['lat']
node['x'] = element['lon']
node['osmid'] = ele... | def get_node(element):
"""
Convert an OSM node element into the format for a networkx node.
Parameters
----------
element : dict
an OSM node element
Returns
-------
dict
"""
node = {}
node['y'] = element['lat']
node['x'] = element['lon']
node['osmid'] = ele... | [
"Convert",
"an",
"OSM",
"node",
"element",
"into",
"the",
"format",
"for",
"a",
"networkx",
"node",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L795-L817 | [
"def",
"get_node",
"(",
"element",
")",
":",
"node",
"=",
"{",
"}",
"node",
"[",
"'y'",
"]",
"=",
"element",
"[",
"'lat'",
"]",
"node",
"[",
"'x'",
"]",
"=",
"element",
"[",
"'lon'",
"]",
"node",
"[",
"'osmid'",
"]",
"=",
"element",
"[",
"'id'",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_path | Convert an OSM way element into the format for a networkx graph path.
Parameters
----------
element : dict
an OSM way element
Returns
-------
dict | osmnx/core.py | def get_path(element):
"""
Convert an OSM way element into the format for a networkx graph path.
Parameters
----------
element : dict
an OSM way element
Returns
-------
dict
"""
path = {}
path['osmid'] = element['id']
# remove any consecutive duplicate element... | def get_path(element):
"""
Convert an OSM way element into the format for a networkx graph path.
Parameters
----------
element : dict
an OSM way element
Returns
-------
dict
"""
path = {}
path['osmid'] = element['id']
# remove any consecutive duplicate element... | [
"Convert",
"an",
"OSM",
"way",
"element",
"into",
"the",
"format",
"for",
"a",
"networkx",
"graph",
"path",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L820-L845 | [
"def",
"get_path",
"(",
"element",
")",
":",
"path",
"=",
"{",
"}",
"path",
"[",
"'osmid'",
"]",
"=",
"element",
"[",
"'id'",
"]",
"# remove any consecutive duplicate elements in the list of nodes",
"grouped_list",
"=",
"groupby",
"(",
"element",
"[",
"'nodes'",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | parse_osm_nodes_paths | Construct dicts of nodes and paths with key=osmid and value=dict of
attributes.
Parameters
----------
osm_data : dict
JSON response from from the Overpass API
Returns
-------
nodes, paths : tuple | osmnx/core.py | def parse_osm_nodes_paths(osm_data):
"""
Construct dicts of nodes and paths with key=osmid and value=dict of
attributes.
Parameters
----------
osm_data : dict
JSON response from from the Overpass API
Returns
-------
nodes, paths : tuple
"""
nodes = {}
paths = {... | def parse_osm_nodes_paths(osm_data):
"""
Construct dicts of nodes and paths with key=osmid and value=dict of
attributes.
Parameters
----------
osm_data : dict
JSON response from from the Overpass API
Returns
-------
nodes, paths : tuple
"""
nodes = {}
paths = {... | [
"Construct",
"dicts",
"of",
"nodes",
"and",
"paths",
"with",
"key",
"=",
"osmid",
"and",
"value",
"=",
"dict",
"of",
"attributes",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L848-L873 | [
"def",
"parse_osm_nodes_paths",
"(",
"osm_data",
")",
":",
"nodes",
"=",
"{",
"}",
"paths",
"=",
"{",
"}",
"for",
"element",
"in",
"osm_data",
"[",
"'elements'",
"]",
":",
"if",
"element",
"[",
"'type'",
"]",
"==",
"'node'",
":",
"key",
"=",
"element",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | remove_isolated_nodes | Remove from a graph all the nodes that have no incident edges (ie, node
degree = 0).
Parameters
----------
G : networkx multidigraph
the graph from which to remove nodes
Returns
-------
networkx multidigraph | osmnx/core.py | def remove_isolated_nodes(G):
"""
Remove from a graph all the nodes that have no incident edges (ie, node
degree = 0).
Parameters
----------
G : networkx multidigraph
the graph from which to remove nodes
Returns
-------
networkx multidigraph
"""
isolated_nodes = [n... | def remove_isolated_nodes(G):
"""
Remove from a graph all the nodes that have no incident edges (ie, node
degree = 0).
Parameters
----------
G : networkx multidigraph
the graph from which to remove nodes
Returns
-------
networkx multidigraph
"""
isolated_nodes = [n... | [
"Remove",
"from",
"a",
"graph",
"all",
"the",
"nodes",
"that",
"have",
"no",
"incident",
"edges",
"(",
"ie",
"node",
"degree",
"=",
"0",
")",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L876-L894 | [
"def",
"remove_isolated_nodes",
"(",
"G",
")",
":",
"isolated_nodes",
"=",
"[",
"node",
"for",
"node",
",",
"degree",
"in",
"dict",
"(",
"G",
".",
"degree",
"(",
")",
")",
".",
"items",
"(",
")",
"if",
"degree",
"<",
"1",
"]",
"G",
".",
"remove_nod... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | truncate_graph_dist | Remove everything further than some network distance from a specified node
in graph.
Parameters
----------
G : networkx multidigraph
source_node : int
the node in the graph from which to measure network distances to other
nodes
max_distance : int
remove every node in the... | osmnx/core.py | def truncate_graph_dist(G, source_node, max_distance=1000, weight='length', retain_all=False):
"""
Remove everything further than some network distance from a specified node
in graph.
Parameters
----------
G : networkx multidigraph
source_node : int
the node in the graph from which ... | def truncate_graph_dist(G, source_node, max_distance=1000, weight='length', retain_all=False):
"""
Remove everything further than some network distance from a specified node
in graph.
Parameters
----------
G : networkx multidigraph
source_node : int
the node in the graph from which ... | [
"Remove",
"everything",
"further",
"than",
"some",
"network",
"distance",
"from",
"a",
"specified",
"node",
"in",
"graph",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L897-L937 | [
"def",
"truncate_graph_dist",
"(",
"G",
",",
"source_node",
",",
"max_distance",
"=",
"1000",
",",
"weight",
"=",
"'length'",
",",
"retain_all",
"=",
"False",
")",
":",
"# get the shortest distance between the node and every other node, then",
"# remove every node further t... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | truncate_graph_bbox | Remove every node in graph that falls outside a bounding box.
Needed because overpass returns entire ways that also include nodes outside
the bbox if the way (that is, a way with a single OSM ID) has a node inside
the bbox at some point.
Parameters
----------
G : networkx multidigraph
nort... | osmnx/core.py | def truncate_graph_bbox(G, north, south, east, west, truncate_by_edge=False, retain_all=False):
"""
Remove every node in graph that falls outside a bounding box.
Needed because overpass returns entire ways that also include nodes outside
the bbox if the way (that is, a way with a single OSM ID) has a n... | def truncate_graph_bbox(G, north, south, east, west, truncate_by_edge=False, retain_all=False):
"""
Remove every node in graph that falls outside a bounding box.
Needed because overpass returns entire ways that also include nodes outside
the bbox if the way (that is, a way with a single OSM ID) has a n... | [
"Remove",
"every",
"node",
"in",
"graph",
"that",
"falls",
"outside",
"a",
"bounding",
"box",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L940-L1007 | [
"def",
"truncate_graph_bbox",
"(",
"G",
",",
"north",
",",
"south",
",",
"east",
",",
"west",
",",
"truncate_by_edge",
"=",
"False",
",",
"retain_all",
"=",
"False",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"G",
"=",
"G",
".",
"cop... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | quadrat_cut_geometry | Split a Polygon or MultiPolygon up into sub-polygons of a specified size,
using quadrats.
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to split up into smaller sub-polygons
quadrat_width : numeric
the linear width of the quadrats with which to cut up... | osmnx/core.py | def quadrat_cut_geometry(geometry, quadrat_width, min_num=3, buffer_amount=1e-9):
"""
Split a Polygon or MultiPolygon up into sub-polygons of a specified size,
using quadrats.
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to split up into smaller sub-poly... | def quadrat_cut_geometry(geometry, quadrat_width, min_num=3, buffer_amount=1e-9):
"""
Split a Polygon or MultiPolygon up into sub-polygons of a specified size,
using quadrats.
Parameters
----------
geometry : shapely Polygon or MultiPolygon
the geometry to split up into smaller sub-poly... | [
"Split",
"a",
"Polygon",
"or",
"MultiPolygon",
"up",
"into",
"sub",
"-",
"polygons",
"of",
"a",
"specified",
"size",
"using",
"quadrats",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1010-L1052 | [
"def",
"quadrat_cut_geometry",
"(",
"geometry",
",",
"quadrat_width",
",",
"min_num",
"=",
"3",
",",
"buffer_amount",
"=",
"1e-9",
")",
":",
"# create n evenly spaced points between the min and max x and y bounds",
"west",
",",
"south",
",",
"east",
",",
"north",
"=",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | intersect_index_quadrats | Intersect points with a polygon, using an r-tree spatial index and cutting
the polygon up into smaller sub-polygons for r-tree acceleration.
Parameters
----------
gdf : GeoDataFrame
the set of points to intersect
geometry : shapely Polygon or MultiPolygon
the geometry to intersect w... | osmnx/core.py | def intersect_index_quadrats(gdf, geometry, quadrat_width=0.05, min_num=3, buffer_amount=1e-9):
"""
Intersect points with a polygon, using an r-tree spatial index and cutting
the polygon up into smaller sub-polygons for r-tree acceleration.
Parameters
----------
gdf : GeoDataFrame
the s... | def intersect_index_quadrats(gdf, geometry, quadrat_width=0.05, min_num=3, buffer_amount=1e-9):
"""
Intersect points with a polygon, using an r-tree spatial index and cutting
the polygon up into smaller sub-polygons for r-tree acceleration.
Parameters
----------
gdf : GeoDataFrame
the s... | [
"Intersect",
"points",
"with",
"a",
"polygon",
"using",
"an",
"r",
"-",
"tree",
"spatial",
"index",
"and",
"cutting",
"the",
"polygon",
"up",
"into",
"smaller",
"sub",
"-",
"polygons",
"for",
"r",
"-",
"tree",
"acceleration",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1055-L1121 | [
"def",
"intersect_index_quadrats",
"(",
"gdf",
",",
"geometry",
",",
"quadrat_width",
"=",
"0.05",
",",
"min_num",
"=",
"3",
",",
"buffer_amount",
"=",
"1e-9",
")",
":",
"# create an empty dataframe to append matches to",
"points_within_geometry",
"=",
"pd",
".",
"D... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | truncate_graph_polygon | Remove every node in graph that falls outside some shapely Polygon or
MultiPolygon.
Parameters
----------
G : networkx multidigraph
polygon : Polygon or MultiPolygon
only retain nodes in graph that lie within this geometry
retain_all : bool
if True, return the entire graph even ... | osmnx/core.py | def truncate_graph_polygon(G, polygon, retain_all=False, truncate_by_edge=False, quadrat_width=0.05, min_num=3, buffer_amount=1e-9):
"""
Remove every node in graph that falls outside some shapely Polygon or
MultiPolygon.
Parameters
----------
G : networkx multidigraph
polygon : Polygon or M... | def truncate_graph_polygon(G, polygon, retain_all=False, truncate_by_edge=False, quadrat_width=0.05, min_num=3, buffer_amount=1e-9):
"""
Remove every node in graph that falls outside some shapely Polygon or
MultiPolygon.
Parameters
----------
G : networkx multidigraph
polygon : Polygon or M... | [
"Remove",
"every",
"node",
"in",
"graph",
"that",
"falls",
"outside",
"some",
"shapely",
"Polygon",
"or",
"MultiPolygon",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1124-L1180 | [
"def",
"truncate_graph_polygon",
"(",
"G",
",",
"polygon",
",",
"retain_all",
"=",
"False",
",",
"truncate_by_edge",
"=",
"False",
",",
"quadrat_width",
"=",
"0.05",
",",
"min_num",
"=",
"3",
",",
"buffer_amount",
"=",
"1e-9",
")",
":",
"start_time",
"=",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | add_edge_lengths | Add length (meters) attribute to each edge by great circle distance between
nodes u and v.
Parameters
----------
G : networkx multidigraph
Returns
-------
G : networkx multidigraph | osmnx/core.py | def add_edge_lengths(G):
"""
Add length (meters) attribute to each edge by great circle distance between
nodes u and v.
Parameters
----------
G : networkx multidigraph
Returns
-------
G : networkx multidigraph
"""
start_time = time.time()
# first load all the edges' o... | def add_edge_lengths(G):
"""
Add length (meters) attribute to each edge by great circle distance between
nodes u and v.
Parameters
----------
G : networkx multidigraph
Returns
-------
G : networkx multidigraph
"""
start_time = time.time()
# first load all the edges' o... | [
"Add",
"length",
"(",
"meters",
")",
"attribute",
"to",
"each",
"edge",
"by",
"great",
"circle",
"distance",
"between",
"nodes",
"u",
"and",
"v",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1183-L1217 | [
"def",
"add_edge_lengths",
"(",
"G",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"# first load all the edges' origin and destination coordinates as a",
"# dataframe indexed by u, v, key",
"coords",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"u",
",",
"v... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | add_path | Add a path to the graph.
Parameters
----------
G : networkx multidigraph
data : dict
the attributes of the path
one_way : bool
if this path is one-way or if it is bi-directional
Returns
-------
None | osmnx/core.py | def add_path(G, data, one_way):
"""
Add a path to the graph.
Parameters
----------
G : networkx multidigraph
data : dict
the attributes of the path
one_way : bool
if this path is one-way or if it is bi-directional
Returns
-------
None
"""
# extract the ... | def add_path(G, data, one_way):
"""
Add a path to the graph.
Parameters
----------
G : networkx multidigraph
data : dict
the attributes of the path
one_way : bool
if this path is one-way or if it is bi-directional
Returns
-------
None
"""
# extract the ... | [
"Add",
"a",
"path",
"to",
"the",
"graph",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1220-L1256 | [
"def",
"add_path",
"(",
"G",
",",
"data",
",",
"one_way",
")",
":",
"# extract the ordered list of nodes from this path element, then delete it",
"# so we don't add it as an attribute to the edge later",
"path_nodes",
"=",
"data",
"[",
"'nodes'",
"]",
"del",
"data",
"[",
"'... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | add_paths | Add a collection of paths to the graph.
Parameters
----------
G : networkx multidigraph
paths : dict
the paths from OSM
bidirectional : bool
if True, create bidirectional edges for one-way streets
Returns
-------
None | osmnx/core.py | def add_paths(G, paths, bidirectional=False):
"""
Add a collection of paths to the graph.
Parameters
----------
G : networkx multidigraph
paths : dict
the paths from OSM
bidirectional : bool
if True, create bidirectional edges for one-way streets
Returns
-------
... | def add_paths(G, paths, bidirectional=False):
"""
Add a collection of paths to the graph.
Parameters
----------
G : networkx multidigraph
paths : dict
the paths from OSM
bidirectional : bool
if True, create bidirectional edges for one-way streets
Returns
-------
... | [
"Add",
"a",
"collection",
"of",
"paths",
"to",
"the",
"graph",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1259-L1305 | [
"def",
"add_paths",
"(",
"G",
",",
"paths",
",",
"bidirectional",
"=",
"False",
")",
":",
"# the list of values OSM uses in its 'oneway' tag to denote True",
"osm_oneway_values",
"=",
"[",
"'yes'",
",",
"'true'",
",",
"'1'",
",",
"'-1'",
"]",
"for",
"data",
"in",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | create_graph | Create a networkx graph from OSM data.
Parameters
----------
response_jsons : list
list of dicts of JSON responses from from the Overpass API
name : string
the name of the graph
retain_all : bool
if True, return the entire graph even if it is not connected
bidirectional ... | osmnx/core.py | def create_graph(response_jsons, name='unnamed', retain_all=False, bidirectional=False):
"""
Create a networkx graph from OSM data.
Parameters
----------
response_jsons : list
list of dicts of JSON responses from from the Overpass API
name : string
the name of the graph
reta... | def create_graph(response_jsons, name='unnamed', retain_all=False, bidirectional=False):
"""
Create a networkx graph from OSM data.
Parameters
----------
response_jsons : list
list of dicts of JSON responses from from the Overpass API
name : string
the name of the graph
reta... | [
"Create",
"a",
"networkx",
"graph",
"from",
"OSM",
"data",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1308-L1371 | [
"def",
"create_graph",
"(",
"response_jsons",
",",
"name",
"=",
"'unnamed'",
",",
"retain_all",
"=",
"False",
",",
"bidirectional",
"=",
"False",
")",
":",
"log",
"(",
"'Creating networkx graph from downloaded OSM data...'",
")",
"start_time",
"=",
"time",
".",
"t... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | bbox_from_point | Create a bounding box some distance in each direction (north, south, east,
and west) from some (lat, lng) point.
Parameters
----------
point : tuple
the (lat, lon) point to create the bounding box around
distance : int
how many meters the north, south, east, and west sides of the bo... | osmnx/core.py | def bbox_from_point(point, distance=1000, project_utm=False, return_crs=False):
"""
Create a bounding box some distance in each direction (north, south, east,
and west) from some (lat, lng) point.
Parameters
----------
point : tuple
the (lat, lon) point to create the bounding box around... | def bbox_from_point(point, distance=1000, project_utm=False, return_crs=False):
"""
Create a bounding box some distance in each direction (north, south, east,
and west) from some (lat, lng) point.
Parameters
----------
point : tuple
the (lat, lon) point to create the bounding box around... | [
"Create",
"a",
"bounding",
"box",
"some",
"distance",
"in",
"each",
"direction",
"(",
"north",
"south",
"east",
"and",
"west",
")",
"from",
"some",
"(",
"lat",
"lng",
")",
"point",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1374-L1416 | [
"def",
"bbox_from_point",
"(",
"point",
",",
"distance",
"=",
"1000",
",",
"project_utm",
"=",
"False",
",",
"return_crs",
"=",
"False",
")",
":",
"# reverse the order of the (lat,lng) point so it is (x,y) for shapely, then",
"# project to UTM and buffer in meters",
"lat",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | graph_from_bbox | Create a networkx graph from OSM data within some bounding box.
Parameters
----------
north : float
northern latitude of bounding box
south : float
southern latitude of bounding box
east : float
eastern longitude of bounding box
west : float
western longitude of ... | osmnx/core.py | def graph_from_bbox(north, south, east, west, network_type='all_private',
simplify=True, retain_all=False, truncate_by_edge=False,
name='unnamed', timeout=180, memory=None,
max_query_area_size=50*1000*50*1000, clean_periphery=True,
infrastr... | def graph_from_bbox(north, south, east, west, network_type='all_private',
simplify=True, retain_all=False, truncate_by_edge=False,
name='unnamed', timeout=180, memory=None,
max_query_area_size=50*1000*50*1000, clean_periphery=True,
infrastr... | [
"Create",
"a",
"networkx",
"graph",
"from",
"OSM",
"data",
"within",
"some",
"bounding",
"box",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1419-L1522 | [
"def",
"graph_from_bbox",
"(",
"north",
",",
"south",
",",
"east",
",",
"west",
",",
"network_type",
"=",
"'all_private'",
",",
"simplify",
"=",
"True",
",",
"retain_all",
"=",
"False",
",",
"truncate_by_edge",
"=",
"False",
",",
"name",
"=",
"'unnamed'",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | graph_from_point | Create a networkx graph from OSM data within some distance of some (lat,
lon) center point.
Parameters
----------
center_point : tuple
the (lat, lon) central point around which to construct the graph
distance : int
retain only those nodes within this many meters of the center of the... | osmnx/core.py | def graph_from_point(center_point, distance=1000, distance_type='bbox',
network_type='all_private', simplify=True, retain_all=False,
truncate_by_edge=False, name='unnamed', timeout=180,
memory=None, max_query_area_size=50*1000*50*1000,
... | def graph_from_point(center_point, distance=1000, distance_type='bbox',
network_type='all_private', simplify=True, retain_all=False,
truncate_by_edge=False, name='unnamed', timeout=180,
memory=None, max_query_area_size=50*1000*50*1000,
... | [
"Create",
"a",
"networkx",
"graph",
"from",
"OSM",
"data",
"within",
"some",
"distance",
"of",
"some",
"(",
"lat",
"lon",
")",
"center",
"point",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1525-L1601 | [
"def",
"graph_from_point",
"(",
"center_point",
",",
"distance",
"=",
"1000",
",",
"distance_type",
"=",
"'bbox'",
",",
"network_type",
"=",
"'all_private'",
",",
"simplify",
"=",
"True",
",",
"retain_all",
"=",
"False",
",",
"truncate_by_edge",
"=",
"False",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | graph_from_address | Create a networkx graph from OSM data within some distance of some address.
Parameters
----------
address : string
the address to geocode and use as the central point around which to
construct the graph
distance : int
retain only those nodes within this many meters of the center... | osmnx/core.py | def graph_from_address(address, distance=1000, distance_type='bbox',
network_type='all_private', simplify=True, retain_all=False,
truncate_by_edge=False, return_coords=False,
name='unnamed', timeout=180, memory=None,
max_query_a... | def graph_from_address(address, distance=1000, distance_type='bbox',
network_type='all_private', simplify=True, retain_all=False,
truncate_by_edge=False, return_coords=False,
name='unnamed', timeout=180, memory=None,
max_query_a... | [
"Create",
"a",
"networkx",
"graph",
"from",
"OSM",
"data",
"within",
"some",
"distance",
"of",
"some",
"address",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1604-L1678 | [
"def",
"graph_from_address",
"(",
"address",
",",
"distance",
"=",
"1000",
",",
"distance_type",
"=",
"'bbox'",
",",
"network_type",
"=",
"'all_private'",
",",
"simplify",
"=",
"True",
",",
"retain_all",
"=",
"False",
",",
"truncate_by_edge",
"=",
"False",
","... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | graph_from_polygon | Create a networkx graph from OSM data within the spatial boundaries of the
passed-in shapely polygon.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
the shape to get network data within. coordinates should be in units of
latitude-longitude degrees.
network_type : st... | osmnx/core.py | def graph_from_polygon(polygon, network_type='all_private', simplify=True,
retain_all=False, truncate_by_edge=False, name='unnamed',
timeout=180, memory=None,
max_query_area_size=50*1000*50*1000,
clean_periphery=True, infrastruc... | def graph_from_polygon(polygon, network_type='all_private', simplify=True,
retain_all=False, truncate_by_edge=False, name='unnamed',
timeout=180, memory=None,
max_query_area_size=50*1000*50*1000,
clean_periphery=True, infrastruc... | [
"Create",
"a",
"networkx",
"graph",
"from",
"OSM",
"data",
"within",
"the",
"spatial",
"boundaries",
"of",
"the",
"passed",
"-",
"in",
"shapely",
"polygon",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1681-L1794 | [
"def",
"graph_from_polygon",
"(",
"polygon",
",",
"network_type",
"=",
"'all_private'",
",",
"simplify",
"=",
"True",
",",
"retain_all",
"=",
"False",
",",
"truncate_by_edge",
"=",
"False",
",",
"name",
"=",
"'unnamed'",
",",
"timeout",
"=",
"180",
",",
"mem... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | graph_from_place | Create a networkx graph from OSM data within the spatial boundaries of some
geocodable place(s).
The query must be geocodable and OSM must have polygon boundaries for the
geocode result. If OSM does not have a polygon for this place, you can
instead get its street network using the graph_from_address f... | osmnx/core.py | def graph_from_place(query, network_type='all_private', simplify=True,
retain_all=False, truncate_by_edge=False, name='unnamed',
which_result=1, buffer_dist=None, timeout=180, memory=None,
max_query_area_size=50*1000*50*1000, clean_periphery=True,
... | def graph_from_place(query, network_type='all_private', simplify=True,
retain_all=False, truncate_by_edge=False, name='unnamed',
which_result=1, buffer_dist=None, timeout=180, memory=None,
max_query_area_size=50*1000*50*1000, clean_periphery=True,
... | [
"Create",
"a",
"networkx",
"graph",
"from",
"OSM",
"data",
"within",
"the",
"spatial",
"boundaries",
"of",
"some",
"geocodable",
"place",
"(",
"s",
")",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1797-L1882 | [
"def",
"graph_from_place",
"(",
"query",
",",
"network_type",
"=",
"'all_private'",
",",
"simplify",
"=",
"True",
",",
"retain_all",
"=",
"False",
",",
"truncate_by_edge",
"=",
"False",
",",
"name",
"=",
"'unnamed'",
",",
"which_result",
"=",
"1",
",",
"buff... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | graph_from_file | Create a networkx graph from OSM data in an XML file.
Parameters
----------
filename : string
the name of a file containing OSM XML data
bidirectional : bool
if True, create bidirectional edges for one-way streets
simplify : bool
if True, simplify the graph topology
reta... | osmnx/core.py | def graph_from_file(filename, bidirectional=False, simplify=True,
retain_all=False, name='unnamed'):
"""
Create a networkx graph from OSM data in an XML file.
Parameters
----------
filename : string
the name of a file containing OSM XML data
bidirectional : bool
... | def graph_from_file(filename, bidirectional=False, simplify=True,
retain_all=False, name='unnamed'):
"""
Create a networkx graph from OSM data in an XML file.
Parameters
----------
filename : string
the name of a file containing OSM XML data
bidirectional : bool
... | [
"Create",
"a",
"networkx",
"graph",
"from",
"OSM",
"data",
"in",
"an",
"XML",
"file",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1885-L1919 | [
"def",
"graph_from_file",
"(",
"filename",
",",
"bidirectional",
"=",
"False",
",",
"simplify",
"=",
"True",
",",
"retain_all",
"=",
"False",
",",
"name",
"=",
"'unnamed'",
")",
":",
"# transmogrify file of OSM XML data into JSON",
"response_jsons",
"=",
"[",
"ove... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | osm_footprints_download | Download OpenStreetMap footprint data.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
geographic shape to fetch the footprints within
north : float
northern latitude of bounding box
south : float
southern latitude of bounding box
east : float
eas... | osmnx/footprints.py | def osm_footprints_download(polygon=None, north=None, south=None, east=None, west=None,
footprint_type='building', timeout=180, memory=None,
max_query_area_size=50*1000*50*1000):
"""
Download OpenStreetMap footprint data.
Parameters
----------
... | def osm_footprints_download(polygon=None, north=None, south=None, east=None, west=None,
footprint_type='building', timeout=180, memory=None,
max_query_area_size=50*1000*50*1000):
"""
Download OpenStreetMap footprint data.
Parameters
----------
... | [
"Download",
"OpenStreetMap",
"footprint",
"data",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L29-L141 | [
"def",
"osm_footprints_download",
"(",
"polygon",
"=",
"None",
",",
"north",
"=",
"None",
",",
"south",
"=",
"None",
",",
"east",
"=",
"None",
",",
"west",
"=",
"None",
",",
"footprint_type",
"=",
"'building'",
",",
"timeout",
"=",
"180",
",",
"memory",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | create_footprints_gdf | Get footprint data from OSM then assemble it into a GeoDataFrame.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
geographic shape to fetch the footprints within
north : float
northern latitude of bounding box
south : float
southern latitude of bounding box
... | osmnx/footprints.py | def create_footprints_gdf(polygon=None, north=None, south=None, east=None, west=None,
footprint_type='building', retain_invalid=False):
"""
Get footprint data from OSM then assemble it into a GeoDataFrame.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
... | def create_footprints_gdf(polygon=None, north=None, south=None, east=None, west=None,
footprint_type='building', retain_invalid=False):
"""
Get footprint data from OSM then assemble it into a GeoDataFrame.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
... | [
"Get",
"footprint",
"data",
"from",
"OSM",
"then",
"assemble",
"it",
"into",
"a",
"GeoDataFrame",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L144-L251 | [
"def",
"create_footprints_gdf",
"(",
"polygon",
"=",
"None",
",",
"north",
"=",
"None",
",",
"south",
"=",
"None",
",",
"east",
"=",
"None",
",",
"west",
"=",
"None",
",",
"footprint_type",
"=",
"'building'",
",",
"retain_invalid",
"=",
"False",
")",
":"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | footprints_from_point | Get footprints within some distance north, south, east, and west of
a lat-long point.
Parameters
----------
point : tuple
a lat-long point
distance : numeric
distance in meters
footprint_type : string
type of footprint to be downloaded. OSM tag key e.g. 'building', 'land... | osmnx/footprints.py | def footprints_from_point(point, distance, footprint_type='building', retain_invalid=False):
"""
Get footprints within some distance north, south, east, and west of
a lat-long point.
Parameters
----------
point : tuple
a lat-long point
distance : numeric
distance in meters
... | def footprints_from_point(point, distance, footprint_type='building', retain_invalid=False):
"""
Get footprints within some distance north, south, east, and west of
a lat-long point.
Parameters
----------
point : tuple
a lat-long point
distance : numeric
distance in meters
... | [
"Get",
"footprints",
"within",
"some",
"distance",
"north",
"south",
"east",
"and",
"west",
"of",
"a",
"lat",
"-",
"long",
"point",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L254-L278 | [
"def",
"footprints_from_point",
"(",
"point",
",",
"distance",
",",
"footprint_type",
"=",
"'building'",
",",
"retain_invalid",
"=",
"False",
")",
":",
"bbox",
"=",
"bbox_from_point",
"(",
"point",
"=",
"point",
",",
"distance",
"=",
"distance",
")",
"north",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | footprints_from_address | Get footprints within some distance north, south, east, and west of
an address.
Parameters
----------
address : string
the address to geocode to a lat-long point
distance : numeric
distance in meters
footprint_type : string
type of footprint to be downloaded. OSM tag key... | osmnx/footprints.py | def footprints_from_address(address, distance, footprint_type='building', retain_invalid=False):
"""
Get footprints within some distance north, south, east, and west of
an address.
Parameters
----------
address : string
the address to geocode to a lat-long point
distance : numeric
... | def footprints_from_address(address, distance, footprint_type='building', retain_invalid=False):
"""
Get footprints within some distance north, south, east, and west of
an address.
Parameters
----------
address : string
the address to geocode to a lat-long point
distance : numeric
... | [
"Get",
"footprints",
"within",
"some",
"distance",
"north",
"south",
"east",
"and",
"west",
"of",
"an",
"address",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L281-L307 | [
"def",
"footprints_from_address",
"(",
"address",
",",
"distance",
",",
"footprint_type",
"=",
"'building'",
",",
"retain_invalid",
"=",
"False",
")",
":",
"# geocode the address string to a (lat, lon) point",
"point",
"=",
"geocode",
"(",
"query",
"=",
"address",
")"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | footprints_from_polygon | Get footprints within some polygon.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
the shape to get data within. coordinates should be in units of
latitude-longitude degrees.
footprint_type : string
type of footprint to be downloaded. OSM tag key e.g. 'building'... | osmnx/footprints.py | def footprints_from_polygon(polygon, footprint_type='building', retain_invalid=False):
"""
Get footprints within some polygon.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
the shape to get data within. coordinates should be in units of
latitude-longitude degrees.
... | def footprints_from_polygon(polygon, footprint_type='building', retain_invalid=False):
"""
Get footprints within some polygon.
Parameters
----------
polygon : shapely Polygon or MultiPolygon
the shape to get data within. coordinates should be in units of
latitude-longitude degrees.
... | [
"Get",
"footprints",
"within",
"some",
"polygon",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L310-L330 | [
"def",
"footprints_from_polygon",
"(",
"polygon",
",",
"footprint_type",
"=",
"'building'",
",",
"retain_invalid",
"=",
"False",
")",
":",
"return",
"create_footprints_gdf",
"(",
"polygon",
"=",
"polygon",
",",
"footprint_type",
"=",
"footprint_type",
",",
"retain_i... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | footprints_from_place | Get footprints within the boundaries of some place.
The query must be geocodable and OSM must have polygon boundaries for the
geocode result. If OSM does not have a polygon for this place, you can
instead get its footprints using the footprints_from_address function, which
geocodes the place name to a ... | osmnx/footprints.py | def footprints_from_place(place, footprint_type='building', retain_invalid=False):
"""
Get footprints within the boundaries of some place.
The query must be geocodable and OSM must have polygon boundaries for the
geocode result. If OSM does not have a polygon for this place, you can
instead get its... | def footprints_from_place(place, footprint_type='building', retain_invalid=False):
"""
Get footprints within the boundaries of some place.
The query must be geocodable and OSM must have polygon boundaries for the
geocode result. If OSM does not have a polygon for this place, you can
instead get its... | [
"Get",
"footprints",
"within",
"the",
"boundaries",
"of",
"some",
"place",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L333-L360 | [
"def",
"footprints_from_place",
"(",
"place",
",",
"footprint_type",
"=",
"'building'",
",",
"retain_invalid",
"=",
"False",
")",
":",
"city",
"=",
"gdf_from_place",
"(",
"place",
")",
"polygon",
"=",
"city",
"[",
"'geometry'",
"]",
".",
"iloc",
"[",
"0",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | plot_footprints | Plot a GeoDataFrame of footprints.
Parameters
----------
gdf : GeoDataFrame
footprints
fig : figure
ax : axis
figsize : tuple
color : string
the color of the footprints
bgcolor : string
the background color of the plot
set_bounds : bool
if True, set b... | osmnx/footprints.py | def plot_footprints(gdf, fig=None, ax=None, figsize=None, color='#333333', bgcolor='w',
set_bounds=True, bbox=None, save=False, show=True, close=False,
filename='image', file_format='png', dpi=600):
"""
Plot a GeoDataFrame of footprints.
Parameters
----------
... | def plot_footprints(gdf, fig=None, ax=None, figsize=None, color='#333333', bgcolor='w',
set_bounds=True, bbox=None, save=False, show=True, close=False,
filename='image', file_format='png', dpi=600):
"""
Plot a GeoDataFrame of footprints.
Parameters
----------
... | [
"Plot",
"a",
"GeoDataFrame",
"of",
"footprints",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L363-L442 | [
"def",
"plot_footprints",
"(",
"gdf",
",",
"fig",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"figsize",
"=",
"None",
",",
"color",
"=",
"'#333333'",
",",
"bgcolor",
"=",
"'w'",
",",
"set_bounds",
"=",
"True",
",",
"bbox",
"=",
"None",
",",
"save",
"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | add_node_elevations | Get the elevation (meters) of each node in the network and add it to the
node as an attribute.
Parameters
----------
G : networkx multidigraph
api_key : string
your google maps elevation API key
max_locations_per_batch : int
max number of coordinate pairs to submit in each API c... | osmnx/elevation.py | def add_node_elevations(G, api_key, max_locations_per_batch=350,
pause_duration=0.02): # pragma: no cover
"""
Get the elevation (meters) of each node in the network and add it to the
node as an attribute.
Parameters
----------
G : networkx multidigraph
api_key : stri... | def add_node_elevations(G, api_key, max_locations_per_batch=350,
pause_duration=0.02): # pragma: no cover
"""
Get the elevation (meters) of each node in the network and add it to the
node as an attribute.
Parameters
----------
G : networkx multidigraph
api_key : stri... | [
"Get",
"the",
"elevation",
"(",
"meters",
")",
"of",
"each",
"node",
"in",
"the",
"network",
"and",
"add",
"it",
"to",
"the",
"node",
"as",
"an",
"attribute",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/elevation.py#L20-L92 | [
"def",
"add_node_elevations",
"(",
"G",
",",
"api_key",
",",
"max_locations_per_batch",
"=",
"350",
",",
"pause_duration",
"=",
"0.02",
")",
":",
"# pragma: no cover",
"# google maps elevation API endpoint",
"url_template",
"=",
"'https://maps.googleapis.com/maps/api/elevatio... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | add_edge_grades | Get the directed grade (ie, rise over run) for each edge in the network and
add it to the edge as an attribute. Nodes must have elevation attributes to
use this function.
Parameters
----------
G : networkx multidigraph
add_absolute : bool
if True, also add the absolute value of the grad... | osmnx/elevation.py | def add_edge_grades(G, add_absolute=True): # pragma: no cover
"""
Get the directed grade (ie, rise over run) for each edge in the network and
add it to the edge as an attribute. Nodes must have elevation attributes to
use this function.
Parameters
----------
G : networkx multidigraph
ad... | def add_edge_grades(G, add_absolute=True): # pragma: no cover
"""
Get the directed grade (ie, rise over run) for each edge in the network and
add it to the edge as an attribute. Nodes must have elevation attributes to
use this function.
Parameters
----------
G : networkx multidigraph
ad... | [
"Get",
"the",
"directed",
"grade",
"(",
"ie",
"rise",
"over",
"run",
")",
"for",
"each",
"edge",
"in",
"the",
"network",
"and",
"add",
"it",
"to",
"the",
"edge",
"as",
"an",
"attribute",
".",
"Nodes",
"must",
"have",
"elevation",
"attributes",
"to",
"u... | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/elevation.py#L96-L125 | [
"def",
"add_edge_grades",
"(",
"G",
",",
"add_absolute",
"=",
"True",
")",
":",
"# pragma: no cover",
"# for each edge, calculate the difference in elevation from origin to",
"# destination, then divide by edge length",
"for",
"u",
",",
"v",
",",
"data",
"in",
"G",
".",
"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | save_gdf_shapefile | Save a GeoDataFrame of place shapes or footprints as an ESRI
shapefile.
Parameters
----------
gdf : GeoDataFrame
the gdf to be saved
filename : string
what to call the shapefile (file extensions are added automatically)
folder : string
where to save the shapefile, if non... | osmnx/save_load.py | def save_gdf_shapefile(gdf, filename=None, folder=None):
"""
Save a GeoDataFrame of place shapes or footprints as an ESRI
shapefile.
Parameters
----------
gdf : GeoDataFrame
the gdf to be saved
filename : string
what to call the shapefile (file extensions are added automatic... | def save_gdf_shapefile(gdf, filename=None, folder=None):
"""
Save a GeoDataFrame of place shapes or footprints as an ESRI
shapefile.
Parameters
----------
gdf : GeoDataFrame
the gdf to be saved
filename : string
what to call the shapefile (file extensions are added automatic... | [
"Save",
"a",
"GeoDataFrame",
"of",
"place",
"shapes",
"or",
"footprints",
"as",
"an",
"ESRI",
"shapefile",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L26-L67 | [
"def",
"save_gdf_shapefile",
"(",
"gdf",
",",
"filename",
"=",
"None",
",",
"folder",
"=",
"None",
")",
":",
"if",
"folder",
"is",
"None",
":",
"folder",
"=",
"settings",
".",
"data_folder",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"make_shp... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | save_graph_shapefile | Save graph nodes and edges as ESRI shapefiles to disk.
Parameters
----------
G : networkx multidigraph
filename : string
the name of the shapefiles (not including file extensions)
folder : string
the folder to contain the shapefiles, if None, use default data folder
encoding : s... | osmnx/save_load.py | def save_graph_shapefile(G, filename='graph', folder=None, encoding='utf-8'):
"""
Save graph nodes and edges as ESRI shapefiles to disk.
Parameters
----------
G : networkx multidigraph
filename : string
the name of the shapefiles (not including file extensions)
folder : string
... | def save_graph_shapefile(G, filename='graph', folder=None, encoding='utf-8'):
"""
Save graph nodes and edges as ESRI shapefiles to disk.
Parameters
----------
G : networkx multidigraph
filename : string
the name of the shapefiles (not including file extensions)
folder : string
... | [
"Save",
"graph",
"nodes",
"and",
"edges",
"as",
"ESRI",
"shapefiles",
"to",
"disk",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L70-L144 | [
"def",
"save_graph_shapefile",
"(",
"G",
",",
"filename",
"=",
"'graph'",
",",
"folder",
"=",
"None",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"if",
"folder",
"is",
"None",
":",
"folder",
"=",
"settin... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | save_graph_osm | Save a graph as an OSM XML formatted file. NOTE: for very large
networks this method can take upwards of 30+ minutes to finish.
Parameters
__________
G : networkx multidigraph or multigraph
filename : string
the name of the osm file (including file extension)
folder : string
the... | osmnx/save_load.py | def save_graph_osm(G, node_tags=settings.osm_xml_node_tags,
node_attrs=settings.osm_xml_node_attrs,
edge_tags=settings.osm_xml_way_tags,
edge_attrs=settings.osm_xml_way_attrs,
oneway=True, filename='graph.osm',
folder=None):
... | def save_graph_osm(G, node_tags=settings.osm_xml_node_tags,
node_attrs=settings.osm_xml_node_attrs,
edge_tags=settings.osm_xml_way_tags,
edge_attrs=settings.osm_xml_way_attrs,
oneway=True, filename='graph.osm',
folder=None):
... | [
"Save",
"a",
"graph",
"as",
"an",
"OSM",
"XML",
"formatted",
"file",
".",
"NOTE",
":",
"for",
"very",
"large",
"networks",
"this",
"method",
"can",
"take",
"upwards",
"of",
"30",
"+",
"minutes",
"to",
"finish",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L147-L235 | [
"def",
"save_graph_osm",
"(",
"G",
",",
"node_tags",
"=",
"settings",
".",
"osm_xml_node_tags",
",",
"node_attrs",
"=",
"settings",
".",
"osm_xml_node_attrs",
",",
"edge_tags",
"=",
"settings",
".",
"osm_xml_way_tags",
",",
"edge_attrs",
"=",
"settings",
".",
"o... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | save_graphml | Save graph as GraphML file to disk.
Parameters
----------
G : networkx multidigraph
filename : string
the name of the graphml file (including file extension)
folder : string
the folder to contain the file, if None, use default data folder
gephi : bool
if True, give each ... | osmnx/save_load.py | def save_graphml(G, filename='graph.graphml', folder=None, gephi=False):
"""
Save graph as GraphML file to disk.
Parameters
----------
G : networkx multidigraph
filename : string
the name of the graphml file (including file extension)
folder : string
the folder to contain th... | def save_graphml(G, filename='graph.graphml', folder=None, gephi=False):
"""
Save graph as GraphML file to disk.
Parameters
----------
G : networkx multidigraph
filename : string
the name of the graphml file (including file extension)
folder : string
the folder to contain th... | [
"Save",
"graph",
"as",
"GraphML",
"file",
"to",
"disk",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L238-L306 | [
"def",
"save_graphml",
"(",
"G",
",",
"filename",
"=",
"'graph.graphml'",
",",
"folder",
"=",
"None",
",",
"gephi",
"=",
"False",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"if",
"folder",
"is",
"None",
":",
"folder",
"=",
"settings",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | load_graphml | Load a GraphML file from disk and convert the node/edge attributes to
correct data types.
Parameters
----------
filename : string
the name of the graphml file (including file extension)
folder : string
the folder containing the file, if None, use default data folder
node_type : ... | osmnx/save_load.py | def load_graphml(filename, folder=None, node_type=int):
"""
Load a GraphML file from disk and convert the node/edge attributes to
correct data types.
Parameters
----------
filename : string
the name of the graphml file (including file extension)
folder : string
the folder co... | def load_graphml(filename, folder=None, node_type=int):
"""
Load a GraphML file from disk and convert the node/edge attributes to
correct data types.
Parameters
----------
filename : string
the name of the graphml file (including file extension)
folder : string
the folder co... | [
"Load",
"a",
"GraphML",
"file",
"from",
"disk",
"and",
"convert",
"the",
"node",
"/",
"edge",
"attributes",
"to",
"correct",
"data",
"types",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L309-L393 | [
"def",
"load_graphml",
"(",
"filename",
",",
"folder",
"=",
"None",
",",
"node_type",
"=",
"int",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"# read the graph from disk",
"if",
"folder",
"is",
"None",
":",
"folder",
"=",
"settings",
".",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | is_duplicate_edge | Check if two edge data dictionaries are the same based on OSM ID and
geometry.
Parameters
----------
data : dict
the first edge's data
data_other : dict
the second edge's data
Returns
-------
is_dupe : bool | osmnx/save_load.py | def is_duplicate_edge(data, data_other):
"""
Check if two edge data dictionaries are the same based on OSM ID and
geometry.
Parameters
----------
data : dict
the first edge's data
data_other : dict
the second edge's data
Returns
-------
is_dupe : bool
"""
... | def is_duplicate_edge(data, data_other):
"""
Check if two edge data dictionaries are the same based on OSM ID and
geometry.
Parameters
----------
data : dict
the first edge's data
data_other : dict
the second edge's data
Returns
-------
is_dupe : bool
"""
... | [
"Check",
"if",
"two",
"edge",
"data",
"dictionaries",
"are",
"the",
"same",
"based",
"on",
"OSM",
"ID",
"and",
"geometry",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L396-L434 | [
"def",
"is_duplicate_edge",
"(",
"data",
",",
"data_other",
")",
":",
"is_dupe",
"=",
"False",
"# if either edge's OSM ID contains multiple values (due to simplification), we want",
"# to compare as sets so they are order-invariant, otherwise uv does not match vu",
"osmid",
"=",
"set",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | is_same_geometry | Check if LineString geometries in two edges are the same, in
normal or reversed order of points.
Parameters
----------
ls1 : LineString
the first edge's geometry
ls2 : LineString
the second edge's geometry
Returns
-------
bool | osmnx/save_load.py | def is_same_geometry(ls1, ls2):
"""
Check if LineString geometries in two edges are the same, in
normal or reversed order of points.
Parameters
----------
ls1 : LineString
the first edge's geometry
ls2 : LineString
the second edge's geometry
Returns
-------
bool... | def is_same_geometry(ls1, ls2):
"""
Check if LineString geometries in two edges are the same, in
normal or reversed order of points.
Parameters
----------
ls1 : LineString
the first edge's geometry
ls2 : LineString
the second edge's geometry
Returns
-------
bool... | [
"Check",
"if",
"LineString",
"geometries",
"in",
"two",
"edges",
"are",
"the",
"same",
"in",
"normal",
"or",
"reversed",
"order",
"of",
"points",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L437-L464 | [
"def",
"is_same_geometry",
"(",
"ls1",
",",
"ls2",
")",
":",
"# extract geometries from each edge data dict",
"geom1",
"=",
"[",
"list",
"(",
"coords",
")",
"for",
"coords",
"in",
"ls1",
".",
"xy",
"]",
"geom2",
"=",
"[",
"list",
"(",
"coords",
")",
"for",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | update_edge_keys | Update the keys of edges that share a u, v with another edge but differ in
geometry. For example, two one-way streets from u to v that bow away from
each other as separate streets, rather than opposite direction edges of a
single street.
Parameters
----------
G : networkx multidigraph
... | osmnx/save_load.py | def update_edge_keys(G):
"""
Update the keys of edges that share a u, v with another edge but differ in
geometry. For example, two one-way streets from u to v that bow away from
each other as separate streets, rather than opposite direction edges of a
single street.
Parameters
--------... | def update_edge_keys(G):
"""
Update the keys of edges that share a u, v with another edge but differ in
geometry. For example, two one-way streets from u to v that bow away from
each other as separate streets, rather than opposite direction edges of a
single street.
Parameters
--------... | [
"Update",
"the",
"keys",
"of",
"edges",
"that",
"share",
"a",
"u",
"v",
"with",
"another",
"edge",
"but",
"differ",
"in",
"geometry",
".",
"For",
"example",
"two",
"one",
"-",
"way",
"streets",
"from",
"u",
"to",
"v",
"that",
"bow",
"away",
"from",
"... | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L468-L522 | [
"def",
"update_edge_keys",
"(",
"G",
")",
":",
"# identify all the edges that are duplicates based on a sorted combination",
"# of their origin, destination, and key. that is, edge uv will match edge vu",
"# as a duplicate, but only if they have the same key",
"edges",
"=",
"graph_to_gdfs",
... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | get_undirected | Convert a directed graph to an undirected graph that maintains parallel
edges if geometries differ.
Parameters
----------
G : networkx multidigraph
Returns
-------
networkx multigraph | osmnx/save_load.py | def get_undirected(G):
"""
Convert a directed graph to an undirected graph that maintains parallel
edges if geometries differ.
Parameters
----------
G : networkx multidigraph
Returns
-------
networkx multigraph
"""
start_time = time.time()
# set from/to nodes before m... | def get_undirected(G):
"""
Convert a directed graph to an undirected graph that maintains parallel
edges if geometries differ.
Parameters
----------
G : networkx multidigraph
Returns
-------
networkx multigraph
"""
start_time = time.time()
# set from/to nodes before m... | [
"Convert",
"a",
"directed",
"graph",
"to",
"an",
"undirected",
"graph",
"that",
"maintains",
"parallel",
"edges",
"if",
"geometries",
"differ",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L526-L593 | [
"def",
"get_undirected",
"(",
"G",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"# set from/to nodes before making graph undirected",
"G",
"=",
"G",
".",
"copy",
"(",
")",
"for",
"u",
",",
"v",
",",
"k",
",",
"data",
"in",
"G",
".",
"edg... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | graph_to_gdfs | Convert a graph into node and/or edge GeoDataFrames
Parameters
----------
G : networkx multidigraph
nodes : bool
if True, convert graph nodes to a GeoDataFrame and return it
edges : bool
if True, convert graph edges to a GeoDataFrame and return it
node_geometry : bool
if... | osmnx/save_load.py | def graph_to_gdfs(G, nodes=True, edges=True, node_geometry=True, fill_edge_geometry=True):
"""
Convert a graph into node and/or edge GeoDataFrames
Parameters
----------
G : networkx multidigraph
nodes : bool
if True, convert graph nodes to a GeoDataFrame and return it
edges : bool
... | def graph_to_gdfs(G, nodes=True, edges=True, node_geometry=True, fill_edge_geometry=True):
"""
Convert a graph into node and/or edge GeoDataFrames
Parameters
----------
G : networkx multidigraph
nodes : bool
if True, convert graph nodes to a GeoDataFrame and return it
edges : bool
... | [
"Convert",
"a",
"graph",
"into",
"node",
"and",
"/",
"or",
"edge",
"GeoDataFrames"
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L596-L676 | [
"def",
"graph_to_gdfs",
"(",
"G",
",",
"nodes",
"=",
"True",
",",
"edges",
"=",
"True",
",",
"node_geometry",
"=",
"True",
",",
"fill_edge_geometry",
"=",
"True",
")",
":",
"if",
"not",
"(",
"nodes",
"or",
"edges",
")",
":",
"raise",
"ValueError",
"(",... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | gdfs_to_graph | Convert node and edge GeoDataFrames into a graph
Parameters
----------
gdf_nodes : GeoDataFrame
gdf_edges : GeoDataFrame
Returns
-------
networkx multidigraph | osmnx/save_load.py | def gdfs_to_graph(gdf_nodes, gdf_edges):
"""
Convert node and edge GeoDataFrames into a graph
Parameters
----------
gdf_nodes : GeoDataFrame
gdf_edges : GeoDataFrame
Returns
-------
networkx multidigraph
"""
G = nx.MultiDiGraph()
G.graph['crs'] = gdf_nodes.crs
G.gr... | def gdfs_to_graph(gdf_nodes, gdf_edges):
"""
Convert node and edge GeoDataFrames into a graph
Parameters
----------
gdf_nodes : GeoDataFrame
gdf_edges : GeoDataFrame
Returns
-------
networkx multidigraph
"""
G = nx.MultiDiGraph()
G.graph['crs'] = gdf_nodes.crs
G.gr... | [
"Convert",
"node",
"and",
"edge",
"GeoDataFrames",
"into",
"a",
"graph"
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L679-L714 | [
"def",
"gdfs_to_graph",
"(",
"gdf_nodes",
",",
"gdf_edges",
")",
":",
"G",
"=",
"nx",
".",
"MultiDiGraph",
"(",
")",
"G",
".",
"graph",
"[",
"'crs'",
"]",
"=",
"gdf_nodes",
".",
"crs",
"G",
".",
"graph",
"[",
"'name'",
"]",
"=",
"gdf_nodes",
".",
"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | make_shp_filename | Create a filename string in a consistent format from a place name string.
Parameters
----------
place_name : string
place name to convert into a filename
Returns
-------
string | osmnx/save_load.py | def make_shp_filename(place_name):
"""
Create a filename string in a consistent format from a place name string.
Parameters
----------
place_name : string
place name to convert into a filename
Returns
-------
string
"""
name_pieces = list(reversed(place_name.split(', ')... | def make_shp_filename(place_name):
"""
Create a filename string in a consistent format from a place name string.
Parameters
----------
place_name : string
place name to convert into a filename
Returns
-------
string
"""
name_pieces = list(reversed(place_name.split(', ')... | [
"Create",
"a",
"filename",
"string",
"in",
"a",
"consistent",
"format",
"from",
"a",
"place",
"name",
"string",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L717-L733 | [
"def",
"make_shp_filename",
"(",
"place_name",
")",
":",
"name_pieces",
"=",
"list",
"(",
"reversed",
"(",
"place_name",
".",
"split",
"(",
"', '",
")",
")",
")",
"filename",
"=",
"'-'",
".",
"join",
"(",
"name_pieces",
")",
".",
"lower",
"(",
")",
"."... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | basic_stats | Calculate basic descriptive metric and topological stats for a graph.
For an unprojected lat-lng graph, tolerance and graph units should be in
degrees, and circuity_dist should be 'gc'. For a projected graph, tolerance
and graph units should be in meters (or similar) and circuity_dist should be
'euclid... | osmnx/stats.py | def basic_stats(G, area=None, clean_intersects=False, tolerance=15,
circuity_dist='gc'):
"""
Calculate basic descriptive metric and topological stats for a graph.
For an unprojected lat-lng graph, tolerance and graph units should be in
degrees, and circuity_dist should be 'gc'. For a pr... | def basic_stats(G, area=None, clean_intersects=False, tolerance=15,
circuity_dist='gc'):
"""
Calculate basic descriptive metric and topological stats for a graph.
For an unprojected lat-lng graph, tolerance and graph units should be in
degrees, and circuity_dist should be 'gc'. For a pr... | [
"Calculate",
"basic",
"descriptive",
"metric",
"and",
"topological",
"stats",
"for",
"a",
"graph",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/stats.py#L23-L233 | [
"def",
"basic_stats",
"(",
"G",
",",
"area",
"=",
"None",
",",
"clean_intersects",
"=",
"False",
",",
"tolerance",
"=",
"15",
",",
"circuity_dist",
"=",
"'gc'",
")",
":",
"sq_m_in_sq_km",
"=",
"1e6",
"#there are 1 million sq meters in 1 sq km",
"G_undirected",
"... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | extended_stats | Calculate extended topological stats and metrics for a graph.
Many of these algorithms have an inherently high time complexity. Global
topological analysis of large complex networks is extremely time consuming
and may exhaust computer memory. Consider using function arguments to not
run metrics that re... | osmnx/stats.py | def extended_stats(G, connectivity=False, anc=False, ecc=False, bc=False, cc=False):
"""
Calculate extended topological stats and metrics for a graph.
Many of these algorithms have an inherently high time complexity. Global
topological analysis of large complex networks is extremely time consuming
... | def extended_stats(G, connectivity=False, anc=False, ecc=False, bc=False, cc=False):
"""
Calculate extended topological stats and metrics for a graph.
Many of these algorithms have an inherently high time complexity. Global
topological analysis of large complex networks is extremely time consuming
... | [
"Calculate",
"extended",
"topological",
"stats",
"and",
"metrics",
"for",
"a",
"graph",
"."
] | gboeing/osmnx | python | https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/stats.py#L236-L428 | [
"def",
"extended_stats",
"(",
"G",
",",
"connectivity",
"=",
"False",
",",
"anc",
"=",
"False",
",",
"ecc",
"=",
"False",
",",
"bc",
"=",
"False",
",",
"cc",
"=",
"False",
")",
":",
"stats",
"=",
"{",
"}",
"full_start_time",
"=",
"time",
".",
"time... | be59fd313bcb68af8fc79242c56194f1247e26e2 |
train | backward_induction | r"""
Solve by backward induction a :math:`T`-period finite horizon
discrete dynamic program with stationary reward and transition
probability functions :math:`r` and :math:`q` and discount factor
:math:`\beta \in [0, 1]`.
The optimal value functions :math:`v^*_0, \ldots, v^*_T` and policy
funct... | quantecon/markov/ddp.py | def backward_induction(ddp, T, v_term=None):
r"""
Solve by backward induction a :math:`T`-period finite horizon
discrete dynamic program with stationary reward and transition
probability functions :math:`r` and :math:`q` and discount factor
:math:`\beta \in [0, 1]`.
The optimal value functions ... | def backward_induction(ddp, T, v_term=None):
r"""
Solve by backward induction a :math:`T`-period finite horizon
discrete dynamic program with stationary reward and transition
probability functions :math:`r` and :math:`q` and discount factor
:math:`\beta \in [0, 1]`.
The optimal value functions ... | [
"r",
"Solve",
"by",
"backward",
"induction",
"a",
":",
"math",
":",
"T",
"-",
"period",
"finite",
"horizon",
"discrete",
"dynamic",
"program",
"with",
"stationary",
"reward",
"and",
"transition",
"probability",
"functions",
":",
"math",
":",
"r",
"and",
":",... | QuantEcon/QuantEcon.py | python | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L964-L1027 | [
"def",
"backward_induction",
"(",
"ddp",
",",
"T",
",",
"v_term",
"=",
"None",
")",
":",
"n",
"=",
"ddp",
".",
"num_states",
"vs",
"=",
"np",
".",
"empty",
"(",
"(",
"T",
"+",
"1",
",",
"n",
")",
")",
"sigmas",
"=",
"np",
".",
"empty",
"(",
"... | 26a66c552f2a73967d7efb6e1f4b4c4985a12643 |
train | _has_sorted_sa_indices | Check whether `s_indices` and `a_indices` are sorted in
lexicographic order.
Parameters
----------
s_indices, a_indices : ndarray(ndim=1)
Returns
-------
bool
Whether `s_indices` and `a_indices` are sorted. | quantecon/markov/ddp.py | def _has_sorted_sa_indices(s_indices, a_indices):
"""
Check whether `s_indices` and `a_indices` are sorted in
lexicographic order.
Parameters
----------
s_indices, a_indices : ndarray(ndim=1)
Returns
-------
bool
Whether `s_indices` and `a_indices` are sorted.
"""
... | def _has_sorted_sa_indices(s_indices, a_indices):
"""
Check whether `s_indices` and `a_indices` are sorted in
lexicographic order.
Parameters
----------
s_indices, a_indices : ndarray(ndim=1)
Returns
-------
bool
Whether `s_indices` and `a_indices` are sorted.
"""
... | [
"Check",
"whether",
"s_indices",
"and",
"a_indices",
"are",
"sorted",
"in",
"lexicographic",
"order",
"."
] | QuantEcon/QuantEcon.py | python | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L1074-L1096 | [
"def",
"_has_sorted_sa_indices",
"(",
"s_indices",
",",
"a_indices",
")",
":",
"L",
"=",
"len",
"(",
"s_indices",
")",
"for",
"i",
"in",
"range",
"(",
"L",
"-",
"1",
")",
":",
"if",
"s_indices",
"[",
"i",
"]",
">",
"s_indices",
"[",
"i",
"+",
"1",
... | 26a66c552f2a73967d7efb6e1f4b4c4985a12643 |
train | _generate_a_indptr | Generate `a_indptr`; stored in `out`. `s_indices` is assumed to be
in sorted order.
Parameters
----------
num_states : scalar(int)
s_indices : ndarray(int, ndim=1)
out : ndarray(int, ndim=1)
Length must be num_states+1. | quantecon/markov/ddp.py | def _generate_a_indptr(num_states, s_indices, out):
"""
Generate `a_indptr`; stored in `out`. `s_indices` is assumed to be
in sorted order.
Parameters
----------
num_states : scalar(int)
s_indices : ndarray(int, ndim=1)
out : ndarray(int, ndim=1)
Length must be num_states+1.
... | def _generate_a_indptr(num_states, s_indices, out):
"""
Generate `a_indptr`; stored in `out`. `s_indices` is assumed to be
in sorted order.
Parameters
----------
num_states : scalar(int)
s_indices : ndarray(int, ndim=1)
out : ndarray(int, ndim=1)
Length must be num_states+1.
... | [
"Generate",
"a_indptr",
";",
"stored",
"in",
"out",
".",
"s_indices",
"is",
"assumed",
"to",
"be",
"in",
"sorted",
"order",
"."
] | QuantEcon/QuantEcon.py | python | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L1100-L1121 | [
"def",
"_generate_a_indptr",
"(",
"num_states",
",",
"s_indices",
",",
"out",
")",
":",
"idx",
"=",
"0",
"out",
"[",
"0",
"]",
"=",
"0",
"for",
"s",
"in",
"range",
"(",
"num_states",
"-",
"1",
")",
":",
"while",
"(",
"s_indices",
"[",
"idx",
"]",
... | 26a66c552f2a73967d7efb6e1f4b4c4985a12643 |
train | DiscreteDP._check_action_feasibility | Check that for every state, reward is finite for some action,
and for the case sa_pair is True, that for every state, there is
some action available. | quantecon/markov/ddp.py | def _check_action_feasibility(self):
"""
Check that for every state, reward is finite for some action,
and for the case sa_pair is True, that for every state, there is
some action available.
"""
# Check that for every state, reward is finite for some action
R_max... | def _check_action_feasibility(self):
"""
Check that for every state, reward is finite for some action,
and for the case sa_pair is True, that for every state, there is
some action available.
"""
# Check that for every state, reward is finite for some action
R_max... | [
"Check",
"that",
"for",
"every",
"state",
"reward",
"is",
"finite",
"for",
"some",
"action",
"and",
"for",
"the",
"case",
"sa_pair",
"is",
"True",
"that",
"for",
"every",
"state",
"there",
"is",
"some",
"action",
"available",
"."
] | QuantEcon/QuantEcon.py | python | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L427-L453 | [
"def",
"_check_action_feasibility",
"(",
"self",
")",
":",
"# Check that for every state, reward is finite for some action",
"R_max",
"=",
"self",
".",
"s_wise_max",
"(",
"self",
".",
"R",
")",
"if",
"(",
"R_max",
"==",
"-",
"np",
".",
"inf",
")",
".",
"any",
... | 26a66c552f2a73967d7efb6e1f4b4c4985a12643 |
train | DiscreteDP.to_sa_pair_form | Convert this instance of `DiscreteDP` to SA-pair form
Parameters
----------
sparse : bool, optional(default=True)
Should the `Q` matrix be stored as a sparse matrix?
If true the CSR format is used
Returns
-------
ddp_sa : DiscreteDP
T... | quantecon/markov/ddp.py | def to_sa_pair_form(self, sparse=True):
"""
Convert this instance of `DiscreteDP` to SA-pair form
Parameters
----------
sparse : bool, optional(default=True)
Should the `Q` matrix be stored as a sparse matrix?
If true the CSR format is used
Retur... | def to_sa_pair_form(self, sparse=True):
"""
Convert this instance of `DiscreteDP` to SA-pair form
Parameters
----------
sparse : bool, optional(default=True)
Should the `Q` matrix be stored as a sparse matrix?
If true the CSR format is used
Retur... | [
"Convert",
"this",
"instance",
"of",
"DiscreteDP",
"to",
"SA",
"-",
"pair",
"form"
] | QuantEcon/QuantEcon.py | python | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L455-L485 | [
"def",
"to_sa_pair_form",
"(",
"self",
",",
"sparse",
"=",
"True",
")",
":",
"if",
"self",
".",
"_sa_pair",
":",
"return",
"self",
"else",
":",
"s_ind",
",",
"a_ind",
"=",
"np",
".",
"where",
"(",
"self",
".",
"R",
">",
"-",
"np",
".",
"inf",
")"... | 26a66c552f2a73967d7efb6e1f4b4c4985a12643 |
train | DiscreteDP.to_product_form | Convert this instance of `DiscreteDP` to the "product" form.
The product form uses the version of the init method taking
`R`, `Q` and `beta`.
Parameters
----------
Returns
-------
ddp_sa : DiscreteDP
The correspnoding DiscreteDP instance in product ... | quantecon/markov/ddp.py | def to_product_form(self):
"""
Convert this instance of `DiscreteDP` to the "product" form.
The product form uses the version of the init method taking
`R`, `Q` and `beta`.
Parameters
----------
Returns
-------
ddp_sa : DiscreteDP
Th... | def to_product_form(self):
"""
Convert this instance of `DiscreteDP` to the "product" form.
The product form uses the version of the init method taking
`R`, `Q` and `beta`.
Parameters
----------
Returns
-------
ddp_sa : DiscreteDP
Th... | [
"Convert",
"this",
"instance",
"of",
"DiscreteDP",
"to",
"the",
"product",
"form",
"."
] | QuantEcon/QuantEcon.py | python | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L487-L521 | [
"def",
"to_product_form",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sa_pair",
":",
"ns",
"=",
"self",
".",
"num_states",
"na",
"=",
"self",
".",
"a_indices",
".",
"max",
"(",
")",
"+",
"1",
"R",
"=",
"np",
".",
"full",
"(",
"(",
"ns",
",",
"n... | 26a66c552f2a73967d7efb6e1f4b4c4985a12643 |
train | DiscreteDP.RQ_sigma | Given a policy `sigma`, return the reward vector `R_sigma` and
the transition probability matrix `Q_sigma`.
Parameters
----------
sigma : array_like(int, ndim=1)
Policy vector, of length n.
Returns
-------
R_sigma : ndarray(float, ndim=1)
... | quantecon/markov/ddp.py | def RQ_sigma(self, sigma):
"""
Given a policy `sigma`, return the reward vector `R_sigma` and
the transition probability matrix `Q_sigma`.
Parameters
----------
sigma : array_like(int, ndim=1)
Policy vector, of length n.
Returns
-------
... | def RQ_sigma(self, sigma):
"""
Given a policy `sigma`, return the reward vector `R_sigma` and
the transition probability matrix `Q_sigma`.
Parameters
----------
sigma : array_like(int, ndim=1)
Policy vector, of length n.
Returns
-------
... | [
"Given",
"a",
"policy",
"sigma",
"return",
"the",
"reward",
"vector",
"R_sigma",
"and",
"the",
"transition",
"probability",
"matrix",
"Q_sigma",
"."
] | QuantEcon/QuantEcon.py | python | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L523-L552 | [
"def",
"RQ_sigma",
"(",
"self",
",",
"sigma",
")",
":",
"if",
"self",
".",
"_sa_pair",
":",
"sigma",
"=",
"np",
".",
"asarray",
"(",
"sigma",
")",
"sigma_indices",
"=",
"np",
".",
"empty",
"(",
"self",
".",
"num_states",
",",
"dtype",
"=",
"int",
"... | 26a66c552f2a73967d7efb6e1f4b4c4985a12643 |
train | DiscreteDP.bellman_operator | The Bellman operator, which computes and returns the updated
value function `Tv` for a value function `v`.
Parameters
----------
v : array_like(float, ndim=1)
Value function vector, of length n.
Tv : ndarray(float, ndim=1), optional(default=None)
Optiona... | quantecon/markov/ddp.py | def bellman_operator(self, v, Tv=None, sigma=None):
"""
The Bellman operator, which computes and returns the updated
value function `Tv` for a value function `v`.
Parameters
----------
v : array_like(float, ndim=1)
Value function vector, of length n.
... | def bellman_operator(self, v, Tv=None, sigma=None):
"""
The Bellman operator, which computes and returns the updated
value function `Tv` for a value function `v`.
Parameters
----------
v : array_like(float, ndim=1)
Value function vector, of length n.
... | [
"The",
"Bellman",
"operator",
"which",
"computes",
"and",
"returns",
"the",
"updated",
"value",
"function",
"Tv",
"for",
"a",
"value",
"function",
"v",
"."
] | QuantEcon/QuantEcon.py | python | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L554-L582 | [
"def",
"bellman_operator",
"(",
"self",
",",
"v",
",",
"Tv",
"=",
"None",
",",
"sigma",
"=",
"None",
")",
":",
"vals",
"=",
"self",
".",
"R",
"+",
"self",
".",
"beta",
"*",
"self",
".",
"Q",
".",
"dot",
"(",
"v",
")",
"# Shape: (L,) or (n, m)",
"... | 26a66c552f2a73967d7efb6e1f4b4c4985a12643 |
train | DiscreteDP.T_sigma | Given a policy `sigma`, return the T_sigma operator.
Parameters
----------
sigma : array_like(int, ndim=1)
Policy vector, of length n.
Returns
-------
callable
The T_sigma operator. | quantecon/markov/ddp.py | def T_sigma(self, sigma):
"""
Given a policy `sigma`, return the T_sigma operator.
Parameters
----------
sigma : array_like(int, ndim=1)
Policy vector, of length n.
Returns
-------
callable
The T_sigma operator.
"""
... | def T_sigma(self, sigma):
"""
Given a policy `sigma`, return the T_sigma operator.
Parameters
----------
sigma : array_like(int, ndim=1)
Policy vector, of length n.
Returns
-------
callable
The T_sigma operator.
"""
... | [
"Given",
"a",
"policy",
"sigma",
"return",
"the",
"T_sigma",
"operator",
"."
] | QuantEcon/QuantEcon.py | python | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L584-L600 | [
"def",
"T_sigma",
"(",
"self",
",",
"sigma",
")",
":",
"R_sigma",
",",
"Q_sigma",
"=",
"self",
".",
"RQ_sigma",
"(",
"sigma",
")",
"return",
"lambda",
"v",
":",
"R_sigma",
"+",
"self",
".",
"beta",
"*",
"Q_sigma",
".",
"dot",
"(",
"v",
")"
] | 26a66c552f2a73967d7efb6e1f4b4c4985a12643 |
train | DiscreteDP.compute_greedy | Compute the v-greedy policy.
Parameters
----------
v : array_like(float, ndim=1)
Value function vector, of length n.
sigma : ndarray(int, ndim=1), optional(default=None)
Optional output array for `sigma`.
Returns
-------
sigma : ndarray(... | quantecon/markov/ddp.py | def compute_greedy(self, v, sigma=None):
"""
Compute the v-greedy policy.
Parameters
----------
v : array_like(float, ndim=1)
Value function vector, of length n.
sigma : ndarray(int, ndim=1), optional(default=None)
Optional output array for `sigm... | def compute_greedy(self, v, sigma=None):
"""
Compute the v-greedy policy.
Parameters
----------
v : array_like(float, ndim=1)
Value function vector, of length n.
sigma : ndarray(int, ndim=1), optional(default=None)
Optional output array for `sigm... | [
"Compute",
"the",
"v",
"-",
"greedy",
"policy",
"."
] | QuantEcon/QuantEcon.py | python | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L602-L623 | [
"def",
"compute_greedy",
"(",
"self",
",",
"v",
",",
"sigma",
"=",
"None",
")",
":",
"if",
"sigma",
"is",
"None",
":",
"sigma",
"=",
"np",
".",
"empty",
"(",
"self",
".",
"num_states",
",",
"dtype",
"=",
"int",
")",
"self",
".",
"bellman_operator",
... | 26a66c552f2a73967d7efb6e1f4b4c4985a12643 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.