[postgis-users] Declarative SQL query for non-overlapping buffers given dense points?

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Mon Feb 14 12:26:12 PST 2011


I don't know if this would be fast but I would query those buffers which do not intersects with a Union of the layer... Something like:

SELECT id, name, elevation, geom
FROM peaktable A, (SELECT ST_Union(ST_Buffer(geom, 5)) AS geom FROM peaktable) B
WHERE NOT ST_Intersects(ST_Buffer(A.geom, 5), B.geom)

or maybe better:

SELECT id, name, elevation, geom
FROM peaktable A, (SELECT ST_Union(ST_Buffer(geom, 5)) AS geom FROM peaktable) B
WHERE NOT ST_DWithin(ST_Buffer(A.geom, 5), B.geom, 0)

But I haven't tried them.

Pierre

>-----Original Message-----
>From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-
>bounces at postgis.refractions.net] On Behalf Of Stefan Keller
>Sent: 14 février 2011 14:59
>To: PostGIS Users Discussion
>Subject: Re: [postgis-users] Declarative SQL query for non-overlapping buffers given dense points?
>
>I take the silence as an evidence that there is no declarative
>solution to this challenge :->.
>I think I have to write a stored procedure.
>
>Yours, S.
>
>2011/2/13 Stefan Keller <sfkeller at gmail.com>:
>> Hi
>>
>> Given a table of peaks with the fields id, name, elevation, geom I'd
>> like to write a query which returns to me only those (randomly
>> selected) peaks - i.e. peak buffers say with radius 5 kilometers -
>> which dont 'overlap'. This is motivated by a visualization use case
>> where label names should'nt overlap because of lack of visual space -
>> as well as because of low network capacity between db and client!
>>
>> Any ideas on how to solve this with a declarative SQL query?
>>
>> The only promising approach I found so far was is to define a subquery
>> with ranked buffers and then to select some out of these...
>>
>> -S.
>>
>_______________________________________________
>postgis-users mailing list
>postgis-users at postgis.refractions.net
>http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list