From: Colin <colinflack@fastmail.co.uk>
Subject: [postgis-users] (no subject)
Date: Wed, 16 Feb 2011 11:44:29 +0000
Message-ID: <1297856669.15068.1420960387@webmail.messagingengine.com> (raw)
Hi Steve / Brent
Thanks for replies
Steve: Yes I did look at buffer but I discounted it because a small
number of the polys are at distances well outside the mean and I didnt
see any easy way of including them.
Brents solution with st_distance and a tolerance factor might suffer
from the same problem
And in fact the definition of adjacent doesnt include distance - its
simply that no other polygon crosses some path between any 2
I also have the centroids calced and stored so in my spatial innocence i
devised a solution which almost works and uses ST_Crosses(ST_MakeLine
something like this:
select a.id, b.id, ST_Crosses(ST_MakeLine(a.centroid, b.centroid),
b.geom) as stcrosses
from a, b where a.id = nnn and a.id!=b.id order by stcrosses
I run this per id from program code. I then filter the return to give
adjacents
I'm not at my dev machine right now and I suspect thats not exacty
right(at all!) but what I have isnt affected by distance and almost
works - except occasionally for the very complex and where there are
larger gaps between polys.
so maybe a combination of these methods?
Or since the data wont change often, maybe I just plot them in qgis and
do it manually! ;-)
Colin
On 02/16/2011 05:12 AM, Stephen Woodbridge wrote:
> Colin,
>
> Did you look at buffer?
>
> Not tested but something like this might work where b.id are the
> adjacent id's to a.id with the distance of <tolerance>.
>
> select a.id, b.id from mypolys a, mypolys b
> where a.id != b.id
> and buffer(a.geom, <tolerance>) && b.geom
> and intersects(buffer(a.geom, <tolerance>), b.geom)
>
> -Steve
>
> On 2/15/2011 5:38 PM, Colin wrote:
>> Hi
>>
>> I'm quite new to postgis and spatial databases.
>> competent with sql and db's
>>
>> My problem: How to locate adjacent polygons.
>>
>> I have around around 2k irregular polygons.
>> They've have been calculated as alpha / concave hulls from point sets.
>> They're saved into pg as multipolygons
>>
>> id | description | geom
>>
>> The polygons dont have any regularity with regard to location and
>> interaction
>> the majority are close to a neighbour, but not touching. Typically
>> within +/- 1 - 5% of polygon max dim
>> a small number slightly overlap 1 or more neighbours, usually to quite a
>> small extent
>> their irregular shape can include 'undercuts'
>>
>>
>> I need to identify the adjacent neighbours for each polygon
>>
>> I looked at various methods that might allow me to do this but I cant
>> get a 100% solution
>>
>> Can anyone suggest methods that might work
>>
>> thanks
>>
>>
>> Colin
--
http://www.fastmail.fm - A no graphics, no pop-ups email service
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: postgis-users@lists.osgeo.org
Cc: colinflack@fastmail.co.uk
Subject: Re: [postgis-users] (no subject)
In-Reply-To: <1297856669.15068.1420960387@webmail.messagingengine.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox