我正在按照 Geoff Boeing 的 git 中可用的示例(在此处输入链接描述)学习 OSMNX 包,并且学到了很多东西。但是,在示例 10(建筑足迹)中,我遇到了一个问题(我没有足迹的输出,如下图所示)。
代码生成所请求城市空间的街道网络,但不生成足迹(应该如此,如下图以橙色突出显示)。
附言。我没有更改 github 中可用的代码,只是在我阅读它们时给出“Kernel-restart & clearOutput”来重构它们。
附言。在这种情况下,它不会返回错误(返回街景,但不返回重叠建筑物的足迹)当我给谷歌时我找不到解决方案。
import osmnx as ox
from IPython.display import Image
%matplotlib inline
ox.config(log_console=True, use_cache=True)
import os
os.environ["PROJ_LIB"] = "C:/Users/My/Anaconda3/Library/share"
img_folder = 'images'
extension = 'png'
size = 240
gdf = ox.buildings_from_place(place='Piedmont, California, USA')
gdf_proj = ox.project_gdf(gdf)
fig, ax = ox.plot_buildings(gdf_proj, bgcolor='#333333', color='w',
save=True, show=False, close=True, filename='piedmont_bldgs', dpi=40)
Image('{}/{}.{}'.format(img_folder, 'piedmont_bldgs', extension), height=size, width=size)
gdf_save = gdf.drop(labels='nodes', axis=1)
gdf_save.to_file('data/piedmont_bldgs')
areas = gdf_proj.area
areas.head()
sum(areas)
place = ox.gdf_from_place('Piedmont, California, USA')
place_proj = ox.project_gdf(place)
place_proj.area.iloc[0]
sum(areas) / place_proj.area.iloc[0]
point = (48.873446, 2.294255)
dist = 612
gdf = ox.buildings_from_point(point=point, distance=dist)
gdf_proj = ox.project_gdf(gdf)
bbox = ox.bbox_from_point(point=point, distance=dist, project_utm=True)
fig, ax = ox.plot_buildings(gdf_proj, bgcolor='#333333', color='w', figsize=(4,4), bbox=bbox,
save=True, show=False, close=True, filename='paris_bldgs', dpi=90)
Image('{}/{}.{}'.format(img_folder, 'paris_bldgs', extension), height=size, width=size)
# until that moment everything happened according to the tutorial
def make_plot(place, point, network_type='drive', bldg_color='orange', dpi=40,
dist=805, default_width=4, street_widths=None):
gdf = ox.buildings_from_point(point=point, distance=dist)
gdf_proj = ox.project_gdf(gdf)
fig, ax = ox.plot_figure_ground(point=point, dist=dist, network_type=network_type, default_width=default_width,
street_widths=street_widths, save=False, show=False, close=True)
fig, ax = ox.plot_buildings(gdf_proj, fig=fig, ax=ax, color=bldg_color, set_bounds=False,
save=True, show=False, close=True, filename=place, dpi=dpi)
place = 'portland_buildings'
point = (45.517309, -122.682138)
make_plot(place, point)
Image('{}/{}.{}'.format(img_folder, place, extension), height=size, width=size)
# here is the problem
我只得到街道网络作为输出,没有建筑物的足迹(如上图所示)。
信息:
Conda version: 4.6.8
version conda-build: 3.17.8
python version: 3.6.7.final.0
platform: win-64
user-agent: conda / 4.6.8 requests / 2.21.0 CPython / 3.6.7 Windows / 10 Windows / 10.0.17134
nx .__ version__ = '0.9'
如果你能帮助我,我会很高兴。
非常感谢您提前。