Changes between Initial Version and Version 1 of UsersWikiExamplesInsidePolygon


Ignore:
Timestamp:
Apr 14, 2009, 9:13:34 AM (15 years ago)
Author:
pierre
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiExamplesInsidePolygon

    v1 v1  
     1= Examples Inside Polygon =
     2
     3
     4'''Reinhold Stahlmann [http://postgis.refractions.net/pipermail/postgis-users/2004-January/003867.html asks]:'''
     5
     6"How can I built an (OGC-conforming) SQL query with PostGIS to select all Points of a given Point-Dataset who have their Geometry within a specific Polygon-Geometry chosen by a label-Field of the Polygon?  For example: All PostGIS-Users.name (Point-Geometry) within 'Sweden' (Polygon-Geometry)"
     7
     8'''Chris Hodgson [http://postgis.refractions.net/pipermail/postgis-users/2004-January/003868.html answers]:'''
     9
     10{{{
     11SELECT user.name, user.the_geom
     12FROM user
     13WHERE
     14  within( user.the_geom,
     15   (SELECT the_geom
     16    FROM Country
     17    WHERE Country.name = 'Sweden')
     18  )
     19  AND
     20  the_geom &&
     21  (SELECT user.the_geom
     22   FROM Country
     23   WHERE Country.name = 'Sweden')
     24
     25}}}
     26
     27
     28'''Paul Ramsey tries a different approach:'''
     29
     30
     31{{{
     32SELECT user.name, user.the_geom
     33FROM user,
     34 (SELECT the_geom
     35  FROM Country
     36  WHERE Country.name = 'Sweden') as country
     37WHERE
     38  within( user.the_geom, country.the_geom )
     39 AND
     40  the_geom && country.the_geom
     41
     42}}}