[postgis-users] Creating a boundary of an aggregate of buildings

Luca Bertoncello lucabert at lucabert.de
Sun Jan 17 23:25:56 PST 2021


Hi list!

I'm always trying to create a style for a map in ICAO style using data 
from OpenStreetMaps...
Now I'm trying to display the city boundaries.
Problem: in the database I just have the political (administrative) 
boundaries, and I need the physical boundaries.
With "physical boundaries" I mean: I just need to display the part of 
the city with buildings ignoring unused areas and this is mostly littler 
than the political boundaries.

I tried to get them with this query:

       SELECT way
       FROM planet_osm_polygon
       WHERE landuse IN ('residential', 'retail', 'retail;residential')

I think I need many other landuse types, but this is not the problem. 
The problem is, that I have many little areas, and I want to group them, 
so that I can select only the "grouped areas" greater than X.
I found the function ST_ClusterDBSCAN that maybe help me, so I tried the 
query:

       SELECT way, ST_ClusterDBSCAN(way, eps := 50, minpoints := 2) OVER 
() AS cid
       FROM planet_osm_polygon
       WHERE landuse IN ('residential', 'retail', 'retail;residential')

Now I have an "ID" to group the nearing buildings, but I always don't 
have an idea, how to create a boundary over this aggregates...

Can someone help me?

Thanks a lot
Luca Bertoncello
(lucabert at lucabert.de)


More information about the postgis-users mailing list