[postgis-users] within function
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Tue Aug 7 01:37:09 PDT 2007
On Tue, 2007-08-07 at 09:06 +0100, Dave Potts wrote:
> I have a table with a list of places described as Geometry type POINT
> and a table loaded from a shape file, which takes the form of target
> (ie several inscribed circles), each is encoded as a MULTIPOLYGON. I am
> attempting to discover which point lie within within these circle.
>
> I had assumed that something like
>
> select place_name,gid,id,gridcode,area(the_geom) ,
> within(the_geom,os_ngr) from shptbl,place_table wherein (the_geom,os_ngr) ;
>
> would return every geometry ie os_ngr which is within the geometry
> boundries of the_geom.
>
> Where place_name,os_ngr come from place_table and the_geom comes from
> the table shptbl.
>
> Both geometry have the same sri, no errors are listed in the postgres
> log files.
> I have assume that within covers data types of different types (ie POINT
> and MULTIPOLYGON)
>
> Dave.
Hi Dave,
We need a bit more information to help you here; what query results are
you seeing and what query results are you expecting to see? The only
thing I can see is that Within(A, B) returns whether geometry A is
within geometry B rather than vice-versa, so you might need to swap your
parameters to Within().
You may like to try the following (if you have a GiST index on your
the_geom and os_ngr columns then the && will ensure that it can be used
to calculate the much faster bounding box overlap rather than the
complex and slower Within() function):
select place_name, gid, id, gridcode, area(the_geom), within(os_ngr,
the_geom) from shptbl, place_table where
os_ngr && the_geom;
HTH,
Mark.
--
ILande - Open Source Consultancy
http://www.ilande.co.uk
More information about the postgis-users
mailing list