[postgis-users] Points with in multiple Polygons
Obe, Regina
robe.dnd at cityofboston.gov
Tue May 6 05:07:33 PDT 2008
Try
SELECT DISTINCT ON (homes.phonenumber)
homes.phonenumber, homes.the_geom
FROM homes INNER JOIN tornadowarnings ON ST_Within(homes.the_geom,
tornadowarnings.the_geom)
ORDER BY homes.phonenumber
(If you are using the older version of postgis then replace the
ST_Within(homes.the_geom, tornadowarnings.the_geom) with
(Within(homes.the_geom, tornadowarnings.the_geom) AND homes.the_geom &&
tornadowarnings.the_geom)
The DISTINCT ON is only necessary if a home happens to fall into 2
tornadowarning areas (e.g. your tornado warning areas intersect)
If such a thing would never happen, you can leave out the DISTINCT ON
and save some processing time.
Hope that helps,
Regina
-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
chris brisendine
Sent: Tuesday, May 06, 2008 3:44 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Points with in multiple Polygons
I am trying to create a sql query of a a point file aginst the area of
a polygon table with multiple polygons (Points in Polygon), Example I
want to have a listing of phonenumbers from my Homes (Point File
Table) if they are in any of the tornadowarnings (Polygon Table) there
are multiple records in the tornadowarning database also. I tryed
working with the example but have had no luck, any help would be
appreciated. Here is what i was trying to do with the sql I know there
are errors in it.
SELECT homes.phonenumber, homes.the_geom
FROM homes
WHERE
within( homes.the_geom,
(SELECT the_geom
FROM tornadowarnings
)
)
AND
the_geom &&
(SELECT homes.the_geom
FROM tornadowarnings
)
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
More information about the postgis-users
mailing list