[postgis-users] How to locate adjacent polygons?

Stephen Woodbridge woodbri at swoodbridge.com
Tue Feb 15 21:12:23 PST 2011


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
>




More information about the postgis-users mailing list