Intersect Query Issue

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Intersect Query Issue

Jerod Clabaugh
All:

I am trying to get the area as acres from the overlap of 2 polygons.
I have 2 polygon tables, shape.pa and shape_incursion_2005.  I used
the query below and got an answer but its not correct.  Its not
providing the correct area for the overlapping area post-clipping,
but rather pre-clipping.

SELECT (area(shape_incursion_2005.the_geom)* 0.0002471) as acres,
intersection(shape_incursion_2005.the_geom, shape_pa.the_geom) FROM
shape_pa, shape_incursion_2005 WHERE
intersects(shape_incursion_2005.the_geom, shape_pa.the_geom) AND
shape_pa.name = 'Caracol'

In ArcGIS, I would select the polygon I wanted to compare
(shape_pa.name = 'Caracol') and then clip the other table's
overlapping polygons onto it and then calculate the area...

Any ideas on what I am doing wrong?

Thanks in advance,

Jerod Clabaugh
_______________________________________________
postgis-users mailing list
[hidden email]
http://postgis.refractions.net/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

RE: Intersect Query Issue

Aaron Racicot
I am not an SQL expert by any means but I think you are looking for
something more like:

SELECT (area(intersection(first_shp.the_geom, second_shp.the_geom)) *
0.0002471) as acres FROM shape_pa as first_shp, shape_incursion_2005 as
second_shp WHERE intersects(first_shp.the_geom, second_shp.the_geom) AND
fisrt_shp.name = 'Caracol'

You want to take the area of the intersection, not just the whole
original shape once you know that it intersects... there is a subtle
difference.  Your original query would return the area of the original
shape and a new geometry that is the intersection... but never the area
of the intersection.  

You are probably going to need to watch out for types here since
intersection of two shapes type POLYGON will not necessarily return
another POLYGON... it might return a geometry collection, multi-polygon
etc.  I am not sure how particular the AREA function is with these
types.  If you know your data and you know that the intersection will
always return type POLYGON then you might be OK.

Hope this helps more than it hurts!

Aaron


+----------------------------------------+
| Aaron Racicot  | [hidden email]   |
| GIS Programmer | 503.467.0759          |
+----------------------------------------+
| e c o t r u s t                        |
| Jean Vollum Natural Capital Center     |
| 721 NW Ninth Avenue                    |
| Suite 200                              |
| Portland, OR 97209                     |
| www.ecotrust.org                       |
+----------------------------------------+


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of
Jerod Clabaugh
Sent: Wednesday, June 01, 2005 3:02 PM
To: [hidden email]
Subject: [postgis-users] Intersect Query Issue

All:

I am trying to get the area as acres from the overlap of 2 polygons.
I have 2 polygon tables, shape.pa and shape_incursion_2005.  I used
the query below and got an answer but its not correct.  Its not
providing the correct area for the overlapping area post-clipping,
but rather pre-clipping.

SELECT (area(shape_incursion_2005.the_geom)* 0.0002471) as acres,
intersection(shape_incursion_2005.the_geom, shape_pa.the_geom) FROM
shape_pa, shape_incursion_2005 WHERE
intersects(shape_incursion_2005.the_geom, shape_pa.the_geom) AND
shape_pa.name = 'Caracol'

In ArcGIS, I would select the polygon I wanted to compare
(shape_pa.name = 'Caracol') and then clip the other table's
overlapping polygons onto it and then calculate the area...

Any ideas on what I am doing wrong?

Thanks in advance,

Jerod Clabaugh
_______________________________________________
postgis-users mailing list
[hidden email]
http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[hidden email]
http://postgis.refractions.net/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

I can't use contains (Postgis compiled with GEOS)

Jaime Carrera-2
Greetings all,

I'm new to postgis and am trying to show the points
located inside a polygon (I compiled PostGIS by
modifying the Makefile.config file to use GEOS:
USE_GEOS=1\ GEOS_DIR=/usr/local). I'm using the
following query:

SELECT w.id FROM weather as w, muni_mpoly as m WHERE
w.coords && m.grass_poly AND contains
(m.grass_poly,w.coords);

And get the following:

ERROR:  intersects:: operation not implemented -
compile PostGIS with JTS or GEOS support

------
So, I'm doing something wrong here, but I don't know
what it is.

Thanks

Jaime

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/ 
_______________________________________________
postgis-users mailing list
[hidden email]
http://postgis.refractions.net/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: I can't use contains (Postgis compiled with GEOS)

Rhys Ickeringill
Jamie,

I'm still pretty new to all this, so could easily be misguiding you.

If you are using linux, find and cd into the directory where
liblwgeom.so.1.0 resides (mine is in /usr/local/pgsql/lib). Execute `ldd
liblwgeom.so.1.0` and it will give you a listing of the library dependancies
of liblwgeom.so.1.0. In this list should be libgeos.so.2.

If it is not listed at all, you haven't compiled in support for GEOS. If it
is listed as being "not found", you need to move libgeos.so.2.1.1 into a
directory where the linux dynamic linker looks for libraries. How you find
out where this is varies between linux flavours - looking at your
LD_LIBRARY_PATH is one, studying /etc/ld.conf is another.

Given what you have described, I would suggest the first option is most
likely the problem, which means GEOS was not successfully found during
compilation, despite your changes to Makefile.config.

HTH

Rhys



----- Original Message -----
From: "Jaime Carrera" <[hidden email]>
To: "PostGIS Users Discussion" <[hidden email]>
Sent: Thursday, June 02, 2005 9:50 AM
Subject: [postgis-users] I can't use contains (Postgis compiled with GEOS)


> Greetings all,
>
> I'm new to postgis and am trying to show the points
> located inside a polygon (I compiled PostGIS by
> modifying the Makefile.config file to use GEOS:
> USE_GEOS=1\ GEOS_DIR=/usr/local). I'm using the
> following query:
>
> SELECT w.id FROM weather as w, muni_mpoly as m WHERE
> w.coords && m.grass_poly AND contains
> (m.grass_poly,w.coords);
>
> And get the following:
>
> ERROR:  intersects:: operation not implemented -
> compile PostGIS with JTS or GEOS support
>
> ------
> So, I'm doing something wrong here, but I don't know
> what it is.
>
> Thanks
>
> Jaime
>
> __________________________________________________
> Correo Yahoo!
> Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
> Regístrate ya - http://correo.espanol.yahoo.com/
> _______________________________________________
> postgis-users mailing list
> [hidden email]
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>

_______________________________________________
postgis-users mailing list
[hidden email]
http://postgis.refractions.net/mailman/listinfo/postgis-users