I'm using the helper function provided here with some modifications for distance and color. I tried it without my changes and it has the same result. I noticed if I used the 'natural' tag that water ways will extend past the figure but I'm not using it in these, only 'building'.
Code being used:
import osmnx as ox
from IPython.display import Image
ox.config(log_console=True, use_cache=True)
bgcolor="#343434"
edge_color="#FFB0E2"
bldg_color="#F4FF6E"
point = (40.7154,-73.9853)
place = 'New York City, NY'
dist = 3000
dpi = 100
# helper funcion to get one-square-mile street networks, building.
footprints, and plot them
def make_plot(place, point, dist, network_type='all',
bldg_color=bldg_color, dpi=dpi,
default_width=0.5,
street_widths = {
"footway": 0.25,
"steps": 0.25,
"pedestrian": 0.25,
"service": 0.25,
"path": 0.25,
"track": 0.25,
"primary": 1,
"secondary": 0.5,
"motorway": 2 ,
}):
tags = {
#'amenity':True,
'building':True,
#'geological':True,
#'historic':True,
#'landuse':['retail', 'commercial'],
#'natural':True,
#'waterway':True,
}
gdf = ox.geometries.geometries_from_point(center_point=point,
tags=tags, dist=dist)
fig, ax = ox.plot.plot_figure_ground(point=point, dist=dist,
network_type=network_type,
default_width=default_width,
street_widths=street_widths,
edge_color=edge_color ,save=False, show=False,
close=True, bgcolor=bgcolor)
fig, ax = ox.plot.plot_footprints(gdf, ax=ax, color=bldg_color,
save=True, show=False, close=True,
filepath="images/us_cities/{}-dist{}-
dpi{}.png".format(place,dist,dpi), dpi=dpi)
make_plot(place, point, dist)
Example output:
Footprint does not extend to the edge of the image. Empty margin on top and bottom of image
Margin on left and right of image, footprint doesn't extend to edges.
Large margin and footprint not filling image. I noticed something in the logs while it was generating the map; two bboxes of different sizes are created. They are bold in the log entries below:
2020-10-04 11:37:28 Configured osmnx 2020-10-04 11:37:28 Created
bbox 3000 m from (40.7154, -73.9853): 40.74237961006479,40.68842038993522,-73.9497049233066,-74.020895076693392020-10-04 11:37:28 Projected GeoDataFrame to +proj=utm +zone=18
+ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs2020-10-04 11:37:28 Projected GeoDataFrame to epsg:4326
2020-10-04 11:37:28 Requesting data within polygon from API in 1 request(s)
2020-10-04 11:37:29 Pausing 0 seconds before making HTTP POST request
2020-10-04 11:37:37 Downloaded 25,341.0KB from overpass-api.de 2020-10-04 11:37:39 Saved response to cache file "cache/5c31a2f980a9dc4969b2dd7541ef5eff.json"
2020-10-04 11:37:39 Got all geometry data within polygon from API in 1 request(s)
2020-10-04 11:37:39 196787 elements in the JSON responses (includes every node).
2020-10-04 11:37:39 Converting elements to geometries
2020-10-04 11:37:42 No outer polygons were created for https://www.openstreetmap.org/relation/7774552
2020-10-04 11:37:42 30055 geometries created in the dict
2020-10-04 11:37:42 376 untagged geometries removed
2020-10-04 11:37:53 Created r-tree spatial index for 29679 geometries
2020-10-04 11:37:54 Identified 29669 geometries inside polygon
2020-10-04 11:37:54 10 geometries removed by the polygon filter
2020-10-04 11:37:54 413 geometries removed by the tag filter
2020-10-04 11:37:56 29265 geometries in the final GeoDataFrame
2020-10-04 11:37:56 Created bbox 3600.0 m from (40.7154, -73.9853): 40.747775532077746,40.68302446792226,-73.94258590796792,-74.02801409203207
2020-10-04 11:37:57 Projected GeoDataFrame to +proj=utm +zone=18 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs
2020-10-04 11:37:57 Projected GeoDataFrame to epsg:4326
2020-10-04 11:37:57 Projected GeoDataFrame to +proj=utm +zone=18 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs
2020-10-04 11:37:57 Projected GeoDataFrame to epsg:4326
2020-10-04 11:37:57 Requesting data within polygon from API in 1 request(s)
2020-10-04 11:37:57 Pausing 0 seconds before making HTTP POST request
The short answer is you are calling
plot_footprints
at the end, but not passing it abbox
argument. So, per the docs, it calculates the figure's bounding box to display from the spatial extents of the geometries. Some of the geometries that intersect your query area also extend far beyond it. Create a bbox that matches your query area and pass it to the plotting function.Here's a simplified but complete working example.