I'm looking for a way to orthogonalize building outlines which I've extracted from a high-res DEM. I'm using the FOSS GIS stack (QGIS, GRASS, SAGA, PostgrSQL, PostGIS) and can code in Python (or Java).
- I want any building corners which meet at nearly 90 degrees to be snapped to exactly 90 degrees, by moving nodes.
- This needs to work on multiple/selected features
- I don't want to manually edit the polygons… there are way too many!
Similar functionality exists in OpenStreetMap, for example in the ID and JOSM editors. If you select a building in the ID editor and press 'O' (letter oh), the corners get tidied up.
This is a blessing for people like me who have poor hand/eye co-ordination when tracing from aerial imagery :) So I know that it's technically possible, and can always reverse-engineer those.
So far I've…
- isolated buildings from the DEM using SAGA, using the DTM Slope-based filter
- used Raster Calculator in QGIS to get a binary raster (1=building, 0=not building)
- converted raster to vector using GDAL
- simplified the polygons, using 0.5m tolerance, to get rid of the 'staircase' effect, where the polygon follows the pixel edges
Now, I have my rough building outlines, I just need to orthogonalise them.
Does anyone know of any tools / plugins / libraries in the FOSS GIS stack which provide this functionality already? Have I overlooked something obvious?