问题
I am trying to plot waterway together with ground (street network/map) and footprints (buildings). My problem is that the waterways are large closed polygon areas, which means instead of plotting a nice blue river with correct thickness it plots the river all over half of the figure (and there's no water there IRL...). This is what I have in Jupyter-Lab so far (example coordinates with few roads for quick test):
%matplotlib inline
import matplotlib.pyplot as plt
import osmnx as ox
ox.config(log_file=True, log_console=True, use_cache=True)
import numpy as np
map_settings = dict(
dist=805,
edge_color='k',
bgcolor='w',
dpi = 300,
point = (45.27386, 25.04644),
default_width=2,
)
fig, ax = ox.plot_figure_ground(network_type='all',
**map_settings,
)
gdf_bldings = ox.footprints.footprints_from_point(point=map_settings['point'],
distance=map_settings['dist'], footprint_type='building',
)
fig, ax = ox.footprints.plot_footprints(gdf_bldings, fig=fig, ax=ax,
set_bounds=False, save=False, show=True, close=False,
dpi=map_settings['dpi'],
)
gdf_water = ox.footprints.footprints_from_point(point=map_settings['point'],
distance=map_settings['dist'], footprint_type='waterway',
)
fig, ax = ox.footprints.plot_footprints(gdf_water, fig=fig, ax=ax, color='b',
set_bounds=False, save=False, show=True, close=False,
dpi=map_settings['dpi'],
)
coslat = np.cos(np.cos(map_settings['point'][1] / 180. * np.pi) )
ax.set_aspect(1/coslat)
fig.set_figwidth(10)
fig
and it gives the following figure.
I tried other places, and it does the same there. Is there any way to fix this to have a nice river as expected? I tried to iterate through the shapely objects and figure out if I could remove the coordinates but it gets ugly pretty fast.
来源:https://stackoverflow.com/questions/55727225/osmnx-visualizing-waterway-together-with-footprints-and-ground