pyrosm icon indicating copy to clipboard operation
pyrosm copied to clipboard

Broken `building`s

Open AdrianKriger opened this issue 6 months ago • 0 comments

Thank you for this amazing library.

If this issue has already been raised forgive the duplicate please. I am harvesting broken some buildings.

import requests
import overpass
import osm2geojson
import geopandas as gpd

import pyrosm

fp = pyrosm.get_data("Cape Town", update=True, directory="data")  

#- get the area [suburb] --different issue. cants see the suburb with `pyrosm`. need to get it this way
query = """[out:json][timeout:30];
            area[boundary=administrative][name='Western Cape'];
            wr[place~"^(sub|town|city|count|state)"][name='Woodstock'](area);
            out geom;
        """

url = "http://overpass-api.de/api/interpreter"
r = requests.get(url, params={'data': query})
area = osm2geojson.json2geojson(r.json())

#read into .gpd
aoi = gpd.GeoDataFrame.from_features(area['features'])
aoi = aoi.set_crs(4326, allow_override=True)

# get the shapely geometry from the aoi.GeoDataFrame
bbox_geom = aoi['geometry'].values[0]
# initiliaze with bounding box
osm = pyrosm.OSM(fp, bounding_box=bbox_geom)
# retrieve buildings
ts = osm.get_buildings(extra_attributes=['addr:suburb', 'building:part', 'rooms', 'beds', 'residential', 'building:min_level'])
print(len(ts), ' buildings')

3772 buildings

#-plot
fig, ax = plt.subplots(figsize=(11, 11))
ts.plot(ax=ax, facecolor='none', edgecolor='purple', alpha=0.2)

image

a) Top Right image

It looks like the bounding_box is cutting the way of some buildings. This one [-> https://www.openstreetmap.org/way/993970406#map=18/-33.926501/18.460349], this one [-> https://www.openstreetmap.org/way/993970405], this one [-> https://www.openstreetmap.org/way/993970404], etc.

b) Bottom Left image

This building [-> https://www.openstreetmap.org/relation/12622346] I do not know why this is happening.

AdrianKriger avatar Aug 28 '24 11:08 AdrianKriger