[MAPSERVER-USERS] PostGIS: Intersection of 2 areas
Paul Ramsey
pramsey at cleverelephant.ca
Thu May 15 07:40:19 PDT 2008
Susanne,
(a) This is more a PostGIS query than a Mapserver query, you might
have better luck on postgis-users.
(b) It's impossible to know if you're getting right or wrong answers
without knowing what geometries you are using. If A.Within(B) then
A.Difference(B) will yield nothing, there will be nothing left.
(c) You can do this op in one pass in SQL. No need for three queries.
SELECT a.gid, b.gid, ST_Difference(a.the_geom, b.the_geom) FROM a, b
WHERE a.gid = $gida AND b.gid = $gidb
P
On Thu, May 15, 2008 at 4:09 AM, SUSANNE <susanne.kalliany at tefis.at> wrote:
>
> Hello,
>
> I am struggling with interserction of 2 areas of the same layer.
>
> $sql= "SELECT the_geom FROM " . $layername . " where gid= " . $gid1;
> $res = pg_query ($sql);
> $row = pg_fetch_array ($res);
> $geom1= $row[0];
>
> $sql= "SELECT the_geom FROM " . $layername . " where gid= " . $gid2;
> $res = pg_query ($sql);
> $row = pg_fetch_array ($res);
> $geom2= $row[0];
>
> $sql= "SELECT ST_Difference($geom1,$geom2)" ;
> $res = pg_query ($sql);
> $row = pg_fetch_array ($res);
> $geom= $row[0];
> ^^^
> The current problem is that the last statement does not return anything !
>
> The final goal of my efforts is to get rid of the common area in one of
> two partially overlapping areas.
>
> Is my approach (see above) proper at all for that purpose ?!?
>
> With many thanks in advance for any comments and suggestions.
>
> Susanne
> --
> View this message in context: http://www.nabble.com/PostGIS%3A-Intersection-of-2-areas-tp17250805p17250805.html
> Sent from the Mapserver - User mailing list archive at Nabble.com.
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
More information about the MapServer-users
mailing list