From 53e411d78b4e2dd940b45002706777f8b4bd3861 Mon Sep 17 00:00:00 2001 From: mfbehrens99 Date: Wed, 10 Mar 2021 11:31:10 +0100 Subject: [PATCH 1/3] Minor formating --- code/draw.py | 4 ++-- code/fetch.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/draw.py b/code/draw.py index 9a584f2..bfb6564 100644 --- a/code/draw.py +++ b/code/draw.py @@ -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))) @@ -179,4 +179,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 From 78ce81721826202382b402e6688911278f8c42cd Mon Sep 17 00:00:00 2001 From: mfbehrens99 Date: Wed, 10 Mar 2021 11:32:00 +0100 Subject: [PATCH 2/3] Import display I recieved error messages that display is not imported --- code/draw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/draw.py b/code/draw.py index bfb6564..e3329dc 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 From 58e27bd9d6adf558fa5c8686f1212f1501e6cc34 Mon Sep 17 00:00:00 2001 From: mfbehrens99 Date: Wed, 10 Mar 2021 11:32:25 +0100 Subject: [PATCH 3/3] Support for coordinates --- code/draw.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/draw.py b/code/draw.py index e3329dc..38043e6 100644 --- a/code/draw.py +++ b/code/draw.py @@ -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