Add OSM building footprint fetcher to exposure module#9
Merged
Conversation
New exposure/osm.py: get_osm_buildings(lat, lon, buffer_deg, ...) -> BuildingCollection. Queries the Overpass API for OSM way["building"] elements inside the bbox and returns each as a BuildingFootprint with its (lat, lon) polygon, area in m^2, OSM id, and tags. Models added to exposure/models.py: - BuildingFootprint (frozen dataclass; immutable polygon and tags) - BuildingCollection (sequence + total_area_m2 helper) Polygon area uses a local equirectangular projection with a cos(lat) factor at the polygon centroid. Building-scale polygons see sub-0.1% error from this approximation, well below the noise of OSM source data. A public `parse_overpass_response(payload)` helper lets tests load a saved Overpass JSON without touching the network. The committed tests/fixtures/robit_bata_osm.json (32 KB, 35 buildings) drives the offline tests; one integration test queries Overpass live for central Vaduz to exercise the full network path. Implemented with stdlib only (urllib + json + math) — no new dependency on osmnx, geopandas, or shapely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
exposure/osm.py:get_osm_buildings(lat, lon, buffer_deg, ...) -> BuildingCollection. Queries the Overpass API for OSMway["building"]elements inside the bbox.exposure/models.py:BuildingFootprint(frozen; immutable polygon and tags)BuildingCollection(sequence +total_area_m2()helper)parse_overpass_response(payload)lets tests load saved JSON without touching the network.Notable: stdlib-only
Implemented with
urllib,json,math— no new dependency onosmnx,geopandas, orshapely. If we later need vector ops (rasterize / spatial joins for damage estimation against HAND), we'll addgeopandasthen.Test plan
len > 10so OSM edits don't break it.Pipeline progress