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

Luca Bertoncello lucabert at lucabert.de
Mon Jan 18 06:01:14 PST 2021


Am 18.01.2021 14:38, schrieb Tomas Straupis:

Hi

>   This statement has problems.
>   You're adding a buffer of 10 then removing a buffer of 500 (so
> basically leaving only very large polygons and they are eroded by
> 500meters). Then you're simplifying the result with a 500m value (a
> lot).
> 
>   Try this:
> 
> UPDATE city_boundaries
> SET way = ST_Makevalid(ST_Multi(ST_Buffer(ST_Buffer(way, 400,
> 'quad_segs=1'), -400, 'quad_segs=1')));

I tried this:

CREATE TABLE city_boundaries AS
   SELECT NEXTVAL('city_boundaries_seq') AS id
         ,0::bigint AS way_area
         ,10 AS res
         ,ST_CollectionExtract(unnest(ST_ClusterWithin(way, 400)), 
3)::geometry(MultiPolygon, 3857) as way
     FROM planet_osm_polygon
    WHERE landuse IN ('residential', 'retail', 'retail;residential', 
'commercial', 'school', 'university');
ALTER TABLE city_boundaries OWNER TO _renderd;

DELETE FROM city_boundaries WHERE ST_Area(ST_Buffer(way, -400)) < 400 
and res = 10;

UPDATE city_boundaries SET way = 
ST_Makevalid(ST_Multi(ST_Buffer(ST_Buffer(way, 400, 'quad_segs=1'), 
-400, 'quad_segs=1')));

UPDATE city_boundaries SET way_area = st_area(way) WHERE res = 10;

This will be better, but:
1) I have always many little areas
2) I miss some "medium areas"
3) the displayed areas have many "holes"

A possible solution to 2) could be to reduce the distance (let's say 200 
meter instead of 400?) but so I'll increase the number of little areas.

I think a right way could be to reduce the distance (see previous) and 
generate an area grouping all near little areas, filling the "inclosed" 
holes in the areas. Then I can search for areas greater than for example 
20 Km².
But I don't know to do that...

Thanks
Luca Bertoncello
(lucabert at lucabert.de)


More information about the postgis-users mailing list