[postgis-users] point-in-poly query

Stephen Woodbridge woodbri at swoodbridge.com
Wed Jan 18 06:00:10 PST 2006

Arnaud Lesauvage wrote:
> John.C.Cartwright at noaa.gov a écrit :
>> Hello,
>> given a table of country polygons and a table of city points, I'm trying
>> to find all the cities that fall w/in a given country.  The query listed
>> below runs slowly and also produces incorrect results.  Can someone
>> correct what I'm doing wrong?
>> select cities.city_name,cities.cntry_name
>> from cities p, country a where p.shape && a.shape and   
>> intersects(p.shape,a.shape) and   a.gmi_cntry = 'USA';   
> I think your query is OK (apart from what Michael pointed out).
> If your cities are points, I'd rather use "within" instead of 
> "intersects" though, but I don't know whether it will run faster or not.

I thought distance(p.shape,a.shape)=0.0 was fastest based on prior 
discussions on this list.


More information about the postgis-users mailing list