Today, I’m revisiting work from 2017. In Brezina, Graser & Leth (2017), we looked at different ways to determine the width of sidewalks in Vienna based on the city’s street surface database.
Inscribed and circumscribed circles were a natural starting point. Circumscribed or bounding circle tools (the smallest circle to enclose an input polygon) have been commonly available in desktop GIS and spatial databases. Inscribed circle tools (the largest circle that fits into an input polygon) used to be less readily available. Lately, support has improved since ST_MaximumInscribedCircle has been added in PostGIS 3.1.0 (requires GEOS >= 3.9.0).
The tricky thing is that ST_MaximumInscribedCircle does not behave like ST_MinimumBoundingCircle. While the bounding circle function returns the circle geometry, the inscribed circle function returns a record containing information on the circle center and radius. Handling the resulting records involves some not so intuitive SQL.
Here is what I’ve come up with to get both the circle geometries as well as the radius values:
WITH foo AS ( SELECT id, ST_MaximumInscribedCircle(geom) AS inscribed_circle, ST_MinimumBoundingRadius(geom) AS bounding_circle FROM demo.sidewalks ) SELECT id, (bounding_circle).radius AS bounding_circle_radius, ST_MinimumBoundingCircle(geom) AS bounding_circle_geom, (inscribed_circle).radius AS inscribed_circle_radius, ST_Buffer((inscribed_circle).center, (inscribed_circle).radius) AS inscribed_circle_geom FROM foo
And here is how the results look like in QGIS, with purple shapeburst fills for bounding circles and green shapeburst fills for inscribed circles:
Brezina, T., Graser, A., & Leth, U. (2017). Geometric methods for estimating representative sidewalk widths applied to Vienna’s streetscape surfaces database. Journal of Geographical Systems, 19(2), 157-174, doi:10.1007/s10109-017-0245-2.