I'm using the sample "make_plot" function shown in the example page on the OSMnx repo page to generate maps of building footprints. The output is a square image, is there any way to adjust the height and width to produce a rectangular file?
I made some changes to the example to use the geometries module instead of the deprecated footprints:
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(place, point, dist)
You are querying a square area, so your plot of the results is correspondingly square. If you query a non-square area, you get a non-square plot:
Note that you get a
fig, ax
back, and you can of course resize your figure the 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 optionalfigsize
argument. See the documentation.The examples were updated a month ago when OSMnx v0.16.0 was released, to reflect the new
geometries
module. Any references to the deprecatedfootprints
module were removed then as well.