[postgis-users] Newbie Question

Adam Vande More adam at imedmobility.com
Wed Aug 27 11:10:05 PDT 2008

Okay this is a bit dated now, but I needed to get everything entered 
correctly before proceeding.  The point-in-polygon method you referenced 
is what I'm looking for and searching for good examples of implementing 
this has not yielded good results.  This is most likely due to my 
ignorance is what I need to look for, so I guess I'm trying to find the 
fastest method of finding the polygon that a point lies within.  The 
points and polygons are predefined and in separate table.  Also gist 
indexes exist on the geom columns so what is the most efficient query of 
returning the polygon a point lies within?

Here is the query I have now:

select imp_territories.store from phone_points,imp_territories where 
phone_points.phone_lat = 39.5457 AND phone_points.phone_long = -89.2935 
AND phone_points.the_geom && imp_territories.the_geom and 
contains(imp_territories.the_geom, phone_points.the_geom); 

It seems to work fine(232 ms), just looking for further input.

Paul Ramsey wrote:
> Well, that's the opposite of the usual point-in-polygon use case
> (given an existing set of polygons and a point input, tell me what
> polygons it falls within), but it's equally tractable.
> You need an input interface, and that will be the hardest part of your
> task. You can do something in Google Maps, if you like, then stuff the
> geometry down into a script (php, asp, whatever) that in turn
> inscribes it into a SQL statement ala:
> select points.id, points.name from points where
> st_contains('POLYGON(....)', points.geometry);
> Where the 'POLYGON(...)' is constructed by your script from your user
> interface input.
> Enjoy,
> P.
> On Tue, Aug 5, 2008 at 12:24 PM, Adam Vande More <adam at imedmobility.com> wrote:
>> Hello,
>> Perhaps my questions were addressed earlier or in some documentation I
>> missed. If so, I apologize in advance as I am completely new to GIS and
>> PostGIS.  Judging from the documentation I have read, my needs are extremely
>> simple vs PostGIS capabilities however I am unsure if the functionality of
>> what I want actually exists.
>> I deal with areas in the US, territories that are regional in nature but not
>> bounded by common things eg state lines, water ways, counties, etc.  They
>> are irregular shapes of varying land area.  I also have sets of latitude and
>> longitude points.  I would like some type of system where I enter in a
>> perimeter of  territories, and find out whether a particular latitude and
>> longitude point lies within that perimeter.
>> My understanding of this is that I would need to either manually create a
>> GML type file with the perimeters in it, or use some type of map authoring
>> software to accomplish this goal.  Are my understandings correct and if so
>> is there a recommendation for a particular piece of software which can
>> fulfill this?
>> Also, are the libraries/functions available for determining whether a point
>> is in a perimeter?
>> Much appreciated,
>> --
>> Adam Vandemore
>> Systems Administrator
>> IMED Mobility
>> (605) 498-1610
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

Adam Vande More
Systems Administrator
IMED Mobility
(605) 498-1610 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080827/af1a8002/attachment.html>

More information about the postgis-users mailing list