Skip to content

Commit

Permalink
Merge pull request marceloprates#13 from CharbelAD/main
Browse files Browse the repository at this point in the history
Added buffer distance in get_streets()
  • Loading branch information
marceloprates authored Aug 28, 2021
2 parents 3a609eb e938eaa commit 3646a49
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions prettymaps/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 80,21 @@ def get_geometries(perimeter = None, point = None, radius = None, tags = {}, per
return geometries

# Get streets
def get_streets(perimeter = None, point = None, radius = None, layer = 'streets', width = 6, custom_filter = None, circle = True, dilate = 0):
def get_streets(perimeter = None, point = None, radius = None, layer = 'streets', width = 6, custom_filter = None, buffer = 0,circle = True, dilate = 0):

if layer == 'streets':
layer = 'highway'

# Boundary defined by polygon (perimeter)
if perimeter is not None:
# Fetch streets data, project & convert to GDF
streets = ox.graph_from_polygon(unary_union(perimeter.geometry), custom_filter = custom_filter)
streets = ox.graph_from_polygon(unary_union(perimeter.geometry).buffer(buffer) if buffer > 0 else unary_union(perimeter.geometry), custom_filter = custom_filter)
streets = ox.project_graph(streets)
streets = ox.graph_to_gdfs(streets, nodes = False)
# Boundary defined by polygon (perimeter)
elif (point is not None) and (radius is not None):
# Fetch streets data, save CRS & project
streets = ox.graph_from_point(point, dist = radius dilate, custom_filter = custom_filter)
streets = ox.graph_from_point(point, dist = radius dilate buffer, custom_filter = custom_filter)
crs = ox.graph_to_gdfs(streets, nodes = False).crs
streets = ox.project_graph(streets)
# Compute perimeter from point & CRS
Expand Down Expand Up @@ -146,4 146,4 @@ def get_layer(layer, **kwargs):
return get_streets(**kwargs, layer = layer)
# Fetch geometries
else:
return get_geometries(**kwargs)
return get_geometries(**kwargs)

0 comments on commit 3646a49

Please sign in to comment.