RE: [postgis-users] WHERE POINT @ the_geom; returning two polygons/zip codes instead of one
Matt Farley
mfarley at sac-yolomvcd.com
Thu Aug 25 08:36:10 PDT 2005
Thanks Steve, worked like a charm, you were right on.
I use the Contains function now:
SELECT zip FROM zipcodes WHERE POINT '(-121.447,38.570264)' @ the_geom AND
Contains(the_geom, POINT '(-121.446,38.570264)');
I believe the @ gives me an index to speed things up.
-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Steve Wormley
Sent: Wednesday, August 24, 2005 3:35 PM
To: mfarley at sac-yolomvcd.com, PostGIS Users Discussion
Subject: Re: [postgis-users] WHERE POINT @ the_geom; returning two polygons/zip codes instead of one
On 2005-08-24 14:53, "Matt Farley" <mfarley at sac-yolomvcd.com> wrote:
> SELECT zip FROM zipcodes WHERE POINT '(-121.447,38.570264)' @
> the_geom; - Returns two zip codes, 95816 and 95819
>
> However
> (a 0.001 longitude change to the east)
> SELECT zip FROM zipcodes WHERE POINT '(-121.446,38.570264)' @
> the_geom; - Returns zip code 95819 properly
>
> Both points are in 95819 and are near the border of 95816.
>
> Any idea why the first query is returning both 95816 and 95819 -- the
> point should only be found in 95819.
If the areas you imported are not exactly square then their bounding boxes may overlap and thus the @ operator will return multiple matches.
You'll need to use Intersects or Within or distance(a,b) = 0
to determine exactly which zip code they are in.
For speed you'll need an indexable query for your geometry index (I believe @ counts) before you use the more expensive Intersects query.
-Steve
_______________________________________________
postgis-users mailing list postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list