[postgis-users] Attribute query at lat./long. coordinate

Mr. Puneet Kishor punk.kish at gmail.com
Sun Nov 27 11:17:37 PST 2011


On Nov 27, 2011, at 1:09 PM, Peter Weilandt wrote:

> I came across PostGIS in my search for a tool to use in a website.  I want to develop a website that will use a coordinate (lat & long), which is easily obtained from a user on the client side by clicking on a Google map, and then transferring this coordinate to the server side where it will be used to  query 4 shapefiles, with each shapefile containing many (800+) overlapping polygons, extracting the values from 4 fields of the attribute table for each polygon that contains this coordinate (drill-down results), saving these values in tabular format for immediate processing, and then returning derived values to the user on the client side. There is no map generation required, only extracting data from the attribute table. This sounds simple in concept, but is PostGIS a tool that can accomplish the query portion of this process and, if so, are there any examples showing the code to use for such a query?

Sure, PostGIS is a very good tool for this, and if you are using PostGIS, you are no longer talking about Shapefiles... ostensibly you are using PostGIS so you can do away with files. Just load your Shapefiles into Postgres (with the help of PostGIS, of course). Send your lat/lng pair to the server, do your queries using ST_Within or ST_Contains (or whatever your heart desires) and send the data back to the client.

See http://earth-base.org/trees/ for an example. When the trees polys load on the map, click anywhere on North America and see the results in a popup.


--
Puneet Kishor




More information about the postgis-users mailing list