OSMnx:创建矩形建筑足迹

OSMnx: Create rectangular building footprints

我正在使用 OSMnx 存储库页面示例页面中显示的示例“make_plot”函数来生成建筑物足迹图。输出的是正方形的图片,请问有什么办法可以调整高和宽来生成长方形的文件吗?

我对示例进行了一些更改以使用几何模块而不是已弃用的足迹:

def make_plot(place, point, dist, network_type='all', bldg_color='#FF0000', dpi=300,
            default_width=1,
            street_widths = {
                "footway": 0.5,
                "steps": 0.5,
                "pedestrian": 0.5,
                "service": 0.5,
                "path": 0.5,
                "track": 0.5,
                "primary": 0.5,
                "secondary": 0.5,
                "trunk": 1,
                "motorway": 2 ,
                }):
gdf = ox.geometries.geometries_from_point(center_point=point, tags={'building':True}, dist=dist)
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, bgcolor='#343434')
fig, ax = ox.plot.plot_footprints(gdf, ax=ax, color=bldg_color,
                            save=True, show=False, close=True, filepath="images/{}.png".format(place), dpi=dpi)

make_plot(地点,点,距离)

The output is a square image, is there any way to adjust the height and width to produce a rectangular file?

您正在查询一个正方形区域,因此您的结果图是相应的正方形。如果查询 non-square 区域,则会得到 non-square 图:

import osmnx as ox
ox.config(use_cache=True, log_console=True)
gdf = ox.geometries_from_place('Piedmont, CA, USA', tags={'building':True})
fig, ax = ox.plot_footprints(gdf)

请注意,您会得到一个 fig, ax 返回,当然您可以调整您的图形 usual matplotlib way: fig.set_size_inches(9, 3). Note that this resizes your figure rather than stretch it (e.g., from a square to a rectangle). Also note that all OSMnx plotting functions take an optional figsize argument. See the documentation

I made some changes to the example to use the geometries module instead of the deprecated footprints

examples 是在一个月前 OSMnx v0.16.0 发布时更新的,以反映新的 geometries 模块。任何对已弃用 footprints 模块的引用也被删除。