[postgis-users] service areas ( I want a polygon of the areas that only have one provider)

Nicolas Ribot nicolas.ribot at gmail.com
Sat Aug 31 09:05:07 PDT 2013


Hi, If it is the first case your dataset does not contain such
polygons. You could identify polygons with no overlapping with others
with a query:

select gid
from test t
where not exists (
    select 1
    from test t1
    where t1.gid <> t.gid
    and st_intersects(t1.geom, t1.geom)
);

If it is the second one, you can compute the difference between a
polygon and the union of all its intersections with other polygons,
filtering on POLYGON type to keep only areas:

    with inter as (
        select t1.gid, (st_dump(st_intersection(t1.geom, t2.geom))).geom as geom
        from test t1, test t2
        where t1.gid <> t2.gid
        and st_intersects(t1.geom, t2.geom)
    ), unio as (
        select gid, st_union(geom) as geom
        from inter
        where geometryType(geom) = 'POLYGON'
        group by gid
    ) select t.gid, st_difference(t.geom, i.geom) as geom
    from test t left join unio i on t.gid = i.gid

Nicolas


On 31 August 2013 00:58, BladeOfLight16 <bladeoflight16 at gmail.com> wrote:
> On Fri, Aug 23, 2013 at 5:30 AM, Nathaniel Clay <clay.nathaniel at gmail.com>
> wrote:
>>
>> I have a table of polygons that overlap with each other, I need the
>> polygon of the areas that only have one provider eg do not overlap. Please
>> find attached the shape file. Any help would be greatly appreciated!!
>
>
> Your question isn't completely clear. Are you trying to get all the polygons
> that don't overlap another polygon, or are you looking for all the areas
> that contain exactly 1 polygon (as in something akin to symmetric
> difference)?
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


More information about the postgis-users mailing list