<div>Hi Darafei,</div><div><br></div><div>That's excellent, many thanks. I'll explore this.</div><div><br></div><div>All the best wishes,</div><div>Bjoern</div><div><br><div class="gmail_quote"><div>On Tue, 16 May 2017 at 21:32, Darafei "Komяpa" Praliaskouski <<a href="mailto:me@komzpa.net">me@komzpa.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Set up database and import your area of interest:<br><a href="https://switch2osm.org/loading-osm-data/" target="_blank">https://switch2osm.org/loading-osm-data/</a> <br><div><br>You'll also need a software for visualization (QGIS, install QuickMapServices plugin).<br><br>Let's say you want to get the clusters of buildings closer than 60 in Minsk (I just happen to have it at hand).</div><div><br></div><div>You connect to database and issue a query like this:</div><div><br></div><div><pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"Fira Code""><span style="color:rgb(204,120,50);font-weight:bold">create table </span>buildings_clustered <span style="color:rgb(204,120,50);font-weight:bold">as </span>(<br> <span style="color:rgb(204,120,50);font-weight:bold">select<br></span><span style="color:rgb(204,120,50);font-weight:bold"> </span>ST_ConvexHull(<br> <span style="color:rgb(255,198,109);font-style:italic">unnest</span>(<br> ST_ClusterWithin(<br> <span style="background-color:rgb(52,65,52)">way</span><span style="color:rgb(204,120,50)">,<br></span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(104,151,187)">60<br></span><span style="color:rgb(104,151,187)"> </span>)<br> )<br> ) <span style="color:rgb(204,120,50);font-weight:bold">as </span>geom<span style="color:rgb(204,120,50)">,<br></span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(106,135,89)">'block' </span><span style="color:rgb(204,120,50);font-weight:bold">as class<br></span><span style="color:rgb(204,120,50);font-weight:bold"> from </span>planet_osm_polygon<br> <span style="color:rgb(204,120,50);font-weight:bold">where<br></span><span style="color:rgb(204,120,50);font-weight:bold"> </span><span style="color:rgb(152,118,170)">building </span><span style="color:rgb(204,120,50);font-weight:bold">is not null and<br></span><span style="color:rgb(204,120,50);font-weight:bold"> </span>ST_Intersects(<br> <span style="background-color:rgb(52,65,52)">way</span><span style="color:rgb(204,120,50)">,<br></span><span style="color:rgb(204,120,50)"> </span>(<br> <span style="color:rgb(204,120,50);font-weight:bold">select </span><span style="background-color:rgb(52,65,52)">way</span><br> <span style="color:rgb(204,120,50);font-weight:bold">from </span>planet_osm_polygon<br> <span style="color:rgb(204,120,50);font-weight:bold">where </span><span style="color:rgb(152,118,170)">place </span>= <span style="color:rgb(106,135,89)">'city' </span><span style="color:rgb(204,120,50);font-weight:bold">and<br></span><span style="color:rgb(204,120,50);font-weight:bold"> </span><span style="color:rgb(152,118,170);font-weight:bold">name </span>= <span style="color:rgb(106,135,89)">'Минск'<br></span><span style="color:rgb(106,135,89)"> </span>)<br> )<br>)<span style="color:rgb(204,120,50)">;</span></pre>After it finishes, you can look at result in QGIS:</div><div><br></div><img src="cid:15c12f32338cb971f161" alt="image.png" style="width:1024px;max-width:100%"><div><br>To make writing and formatting SQL simple, I use DataGrip (<a href="https://www.jetbrains.com/datagrip/download/" target="_blank">https://www.jetbrains.com/datagrip/download/</a>).</div><br>Docs references:<div><a href="https://postgis.net/docs/manual-dev/ST_ClusterWithin.html" target="_blank">https://postgis.net/docs/manual-dev/ST_ClusterWithin.html</a> </div><div><a href="https://postgis.net/docs/manual-dev/ST_ConvexHull.html" target="_blank">https://postgis.net/docs/manual-dev/ST_ConvexHull.html</a> </div><div><a href="https://postgis.net/docs/manual-dev/ST_ConcaveHull.html" target="_blank">https://postgis.net/docs/manual-dev/ST_ConcaveHull.html</a> </div><div><a href="https://postgis.net/docs/manual-dev/ST_Intersects.html" target="_blank">https://postgis.net/docs/manual-dev/ST_Intersects.html</a> </div><div><br></div><div>Hope these are enough building blocks for your task.<br><br><br><div class="gmail_quote"><div>вт, 16 мая 2017 г. в 21:00, Bjoern Hassler <<a href="mailto:bjohas%2Bmw@gmail.com" target="_blank">bjohas+mw@gmail.com</a>>:<br></div></div></div></div><div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div data-smartmail="gmail_signature">Hi Darafei,</div><div data-smartmail="gmail_signature"><br></div><div data-smartmail="gmail_signature">Thanks for the quick response. I'm not hugely familiar with the tools, but quite possibly that is all that's needed.</div><div data-smartmail="gmail_signature"><br></div><div data-smartmail="gmail_signature">Do you have some code, or link to a recipe or a good page to get started?</div><div data-smartmail="gmail_signature"><br></div><div data-smartmail="gmail_signature">Thanks!</div></div></div><div><div><div data-smartmail="gmail_signature">Bjoern <br> </div></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 16 May 2017 18:34, "Darafei "Komяpa" Praliaskouski" <<a href="mailto:me@komzpa.net" target="_blank">me@komzpa.net</a>> wrote:<br type="attribution"><blockquote class="m_-683622279037949619m_-2559683700751401623quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>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? </p>
<br><div class="gmail_quote"><div class="m_-683622279037949619m_-2559683700751401623elided-text"><div>On аў, 16 мая 2017, 20.28 Bjoern Hassler <<a href="mailto:bjohas%2Bmw@gmail.com" target="_blank">bjohas+mw@gmail.com</a>> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-683622279037949619m_-2559683700751401623elided-text"><div>Hi all,<div><br></div><div>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.</div><div><br></div><div>Would anybody be interested in discussing this, and work out what the options are?</div><div><br></div><div>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.</div><div><br></div><div>All the best wishes,</div><div>Bjoern </div></div></div>
_______________________________________________<br>
dev mailing list<br>
<a href="mailto:dev@openstreetmap.org" target="_blank">dev@openstreetmap.org</a><br>
<a href="https://lists.openstreetmap.org/listinfo/dev" rel="noreferrer" target="_blank">https://lists.openstreetmap.org/listinfo/dev</a><br>
</blockquote></div>
</blockquote></div><br></div></div></div></blockquote></div></div></div></blockquote></div></div>