[OSM-dev] Clustering of points
Darafei "Komяpa" Praliaskouski
me at komzpa.net
Tue May 16 20:31:45 UTC 2017
Set up database and import your area of interest:
https://switch2osm.org/loading-osm-data/
You'll also need a software for visualization (QGIS, install
QuickMapServices plugin).
Let's say you want to get the clusters of buildings closer than 60 in Minsk
(I just happen to have it at hand).
You connect to database and issue a query like this:
create table buildings_clustered as (
select
ST_ConvexHull(
unnest(
ST_ClusterWithin(
way,
60
)
)
) as geom,
'block' as class
from planet_osm_polygon
where
building is not null and
ST_Intersects(
way,
(
select way
from planet_osm_polygon
where place = 'city' and
name = 'Минск'
)
)
);
After it finishes, you can look at result in QGIS:
[image: image.png]
To make writing and formatting SQL simple, I use DataGrip (
https://www.jetbrains.com/datagrip/download/).
Docs references:
https://postgis.net/docs/manual-dev/ST_ClusterWithin.html
https://postgis.net/docs/manual-dev/ST_ConvexHull.html
https://postgis.net/docs/manual-dev/ST_ConcaveHull.html
https://postgis.net/docs/manual-dev/ST_Intersects.html
Hope these are enough building blocks for your task.
вт, 16 мая 2017 г. в 21:00, Bjoern Hassler <bjohas+mw at gmail.com>:
> Hi Darafei,
>
> Thanks for the quick response. I'm not hugely familiar with the tools, but
> quite possibly that is all that's needed.
>
> Do you have some code, or link to a recipe or a good page to get started?
>
> Thanks!
> Bjoern
>
>
> On 16 May 2017 18:34, "Darafei "Komяpa" Praliaskouski" <me at komzpa.net>
> wrote:
>
> Is there anything in this that's not covered by importing OSM data using
> osm2pgsql and then using a combination of PostGIS's ST_ClusterWithin and
> ST_ConvexHull?
>
> On аў, 16 мая 2017, 20.28 Bjoern Hassler <bjohas+mw at gmail.com> wrote:
>
>> Hi all,
>>
>> I'm interested in clustering of OSM points, as sometimes seen on maps, as
>> well as finding convex hulls. Basically the idea is to assist mappers in
>> locating villages in remote areas in sub-saharan Africa.
>>
>> Would anybody be interested in discussing this, and work out what the
>> options are?
>>
>> We're working with health workers in Zambia, and might be able to write a
>> publication on this, in case it's motivation for somebody to participate.
>>
>> All the best wishes,
>> Bjoern
>> _______________________________________________
>> dev mailing list
>> dev at openstreetmap.org
>> https://lists.openstreetmap.org/listinfo/dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20170516/34d5a1df/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 3313053 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20170516/34d5a1df/attachment-0001.png>
More information about the dev
mailing list