osmnx box is enlarged because of included 'natural' and 'land use' tags

275 Views Asked by At

I'm building a dataset of walkable urban street forms with building footprints and natural areas (parks, hills, forests, meadows, etc.) for a comparative urbanism meets deep learning project for my bachelor thesis.

I want to create a dataset of 255 x 255 pixel images of maps of urban areas I've designed using osmnx. With OSMnx I query an area by a lon, lat point and then look at the bounding box of 700 meters around that point. However, my problem here is that the images can't be standardized to a 255 x 255 pixels size, because very often the green areas - like larger meadows or forests - enlarge the image to wholly fit into it, like in this image of Montreal, Canada, where you can see how the green park area is kind of point out of the urban form. My question then would be, if you know any way of preventing this? Any method to fix the bounding box window and just cut off any excess green space that leeks out of it?

Any ideas will be very much appreciated.

Here is the code for used for to create the above image:

import matplotlib.pyplot as plt
import osmnx as ox
import matplotlib.pyplot as plt
%matplotlib inline

center_point = (45.5016889, -73.567256)
center_dist = 700

graph = ox.graph_from_point(center_point, dist = center_dist, dist_type='bbox', network_type='walk')
nodes, edges = ox.graph_to_gdfs(graph)

fig, ax = plt.subplots(figsize=(9,6))

edges.plot(ax=ax, linewidth=1, edgecolor='#BC8F8F')

leisure = ox.footprints_from_point(center_point, dist = center_dist, footprint_type="leisure")
parks = leisure[leisure["leisure"].isin(["pitch","park","playground"])]
parks.plot(ax=ax, facecolor="green")

natural = ox.footprints_from_point(center_point, dist = center_dist, footprint_type="natural")
natural_greens = natural[natural["natural"].isin(["tree","wood","grassland","tree_row","scrub","peak"])]
natural_greens.plot(ax=ax, facecolor="#90ee90")

landuse = ox.footprints_from_point(center_point, dist = center_dist, footprint_type="landuse")
landuse_greens = landuse[landuse["landuse"].isin(["meadow","forest","orchard","farmland","vineyard","farmyard","recreation_ground", "allotments"])]
landuse_greens.plot(ax=ax, facecolor="#FFF9C2")

buildings = ox.footprints_from_point(center_point, dist = center_dist)
buildings.plot(ax=ax, facecolor='#F73C6E', alpha=0.7)

plt.tight_layout()

Thank you!!

0

There are 0 best solutions below