mirror of
https://github.com/marceloprates/prettymaps.git
synced 2025-07-31 11:50:27 +02:00
Merge branch 'main' of github.com:marceloprates/prettymaps into main
This commit is contained in:
13
code/draw.py
13
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''
|
||||
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']
|
||||
return layers_dict['perimeter']
|
||||
|
@@ -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
|
||||
return streets, perimeter
|
||||
|
Reference in New Issue
Block a user