diff --git a/code/draw.py b/code/draw.py index 9a584f2..38043e6 100644 --- a/code/draw.py +++ b/code/draw.py @@ -22,7 +22,7 @@ from geopandas import GeoDataFrame import pandas as pd from functools import reduce from tabulate import tabulate -from IPython.display import Markdown +from IPython.display import Markdown, display from collections.abc import Iterable # Fetch @@ -39,7 +39,7 @@ def show_palette(palette, description = ''): f'![](https://placehold.it/30x30/{c[1:]}/{c[1:]}?text=)' for c in palette ] - + display(Markdown((description))) display(Markdown(tabulate(pd.DataFrame(colorboxes), showindex = False))) @@ -117,7 +117,8 @@ def plot( zorder_streets = None, zorder_building = None, # Whether to fetch data using OSM Id - by_osmid = False + by_osmid = False, + by_coordinates = False, ): ############# @@ -125,7 +126,9 @@ def plot( ############# # Geocode central point - if not by_osmid: + if by_coordinates: + point = (float(query.split(",")[0].strip()), float(query.split(",")[1].strip())) + elif not by_osmid: point = ox.geocode(query) # Fetch perimeter @@ -179,4 +182,4 @@ def plot( plot_shapes(layers_dict[layer], ax, **layer_kwargs[layer]) # Return perimeter - return layers_dict['perimeter'] \ No newline at end of file + return layers_dict['perimeter'] diff --git a/code/fetch.py b/code/fetch.py index 33498a6..3e029fd 100644 --- a/code/fetch.py +++ b/code/fetch.py @@ -44,7 +44,7 @@ def get_footprints(perimeter = None, point = None, radius = None, footprint = 'b # Boundary defined by polygon (perimeter) footprints = ox.geometries_from_polygon(union(perimeter.geometry), tags = {footprint: True} if type(footprint) == str else footprint) perimeter = union(ox.project_gdf(perimeter).geometry) - + elif (point is not None) and (radius is not None): # Boundary defined by circle with radius 'radius' around point footprints = ox.geometries_from_point(point, dist = radius, tags = {footprint: True} if type(footprint) == str else footprint) @@ -100,7 +100,7 @@ def get_streets(perimeter = None, point = None, radius = None, dilate = 6, custo if not isinstance(streets, Iterable): streets = [streets] - + streets = list(map(pathify, streets)) - return streets, perimeter \ No newline at end of file + return streets, perimeter