[postgis-users] Retrieve a feature having point coordinates

Alessandro Candini candini at meeo.it
Tue Dec 27 02:44:16 PST 2011


It seems very complicated for what I need...no other ways to do:

" give me the feature ID which contains this point"?!

I was trying using something like:

SELECT gid,the_geom FROM salzburg WHERE ST_Contains(the_geom, 
ST_PointFromText('POINT(47.7 13.01)', 900913));

but the result is 0 rows.

Is this approach correct?

> Yap, as i said it only works for points. If you have lines or polygons 
> you may build the bounding box of them and try it with st_xmin etc.
> It did it this way:
>
> SELECT id,tags,linestring
> FROM ( SELECT id,tags,linestring,(each(tags)).key AS key FROM ways ) sub
> WHERE st_xmin(st_box2d(linestring)) >=9.362383 AND 
> st_xmax(st_box2d(linestring)) <=9.417143
> AND st_ymin(st_box2d(linestring)) >= 51.478924 AND 
> st_ymax(st_box2d(linestring)) <=51.511413;
>
>
>
> 2011/12/27 Alessandro Candini <candini at meeo.it <mailto:candini at meeo.it>>
>
>     It dosn't work sayng to me the following:
>     ERROR:  Argument to X() must be a point
>
>>     Maybe you want to try it this way:
>>
>>     SELECT gid,geom FROM mytable
>>     WHERE st_x(geom) >=45.19 AND st_x(geom) <=45.21
>>     AND st_y(geom) >=23.29 AND st_y(geom) <=23.31
>>
>>     It finds all points in the given bounding box. But you cannot
>>     specify exactly one point, because there could be more than one
>>     at this point.
>>
>>     Hope that helps although.
>>
>>     Cheers.
>>
>>
>>     2011/12/27 Alessandro Candini <candini at meeo.it
>>     <mailto:candini at meeo.it>>
>>
>>         Hi list.
>>         I'm new to Postgis world and I have a probable dumb question:
>>         I have a shape file inserted into a postgis database through
>>         shp2pgsql utility and I would like to retrieve a feature ID
>>         giving as input a pair of lat/lon coordinates.
>>         Something like "SELECT gid from mytable WHERE
>>         point_is_into(45.2, 23.3);"
>>         How can I achieve this?
>>
>>         Thanks in advance.
>>
>>         -- 
>>         Alessandro Candini
>>         MEEO S.r.l.
>>         Via Saragat 9
>>         I-44122 Ferrara, Italy
>>         Tel: +39 0532 1861501 <tel:%2B39%200532%201861501>
>>         Fax: +39 0532 1861637 <tel:%2B39%200532%201861637>
>>         http://www.meeo.it
>>
>>         ========================================
>>         "ATTENZIONE:le informazioni contenute in questo messaggio sono
>>         da considerarsi confidenziali ed il loro utilizzo è riservato
>>         unicamente
>>         al destinatario sopra indicato. Chi dovesse ricevere questo
>>         messaggio
>>         per errore è tenuto ad informare il mittente ed a rimuoverlo
>>         definitivamente da ogni supporto elettronico o cartaceo."
>>
>>         "WARNING:This message contains confidential and/or proprietary
>>         information which may be subject to privilege or immunity and
>>         which
>>         is intended for use of its addressee only. Should you receive
>>         this
>>         message in error, you are kindly requested to inform the
>>         sender and
>>         to definitively remove it from any paper or electronic format."
>>
>>         _______________________________________________
>>         postgis-users mailing list
>>         postgis-users at postgis.refractions.net
>>         <mailto:postgis-users at postgis.refractions.net>
>>         http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>>
>>
>>
>>     _______________________________________________
>>     postgis-users mailing list
>>     postgis-users at postgis.refractions.net  <mailto:postgis-users at postgis.refractions.net>
>>     http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
>     -- 
>     Alessandro Candini
>     MEEO S.r.l.
>     Via Saragat 9
>     I-44122 Ferrara, Italy
>     Tel:+39 0532 1861501  <tel:%2B39%200532%201861501>
>     Fax:+39 0532 1861637  <tel:%2B39%200532%201861637>
>     http://www.meeo.it
>
>     ========================================
>     "ATTENZIONE:le informazioni contenute in questo messaggio sono
>     da considerarsi confidenziali ed il loro utilizzo è riservato unicamente
>     al destinatario sopra indicato. Chi dovesse ricevere questo messaggio
>     per errore è tenuto ad informare il mittente ed a rimuoverlo
>     definitivamente da ogni supporto elettronico o cartaceo."
>
>     "WARNING:This message contains confidential and/or proprietary
>     information which may be subject to privilege or immunity and which
>     is intended for use of its addressee only. Should you receive this
>     message in error, you are kindly requested to inform the sender and
>     to definitively remove it from any paper or electronic format."
>
>
>     _______________________________________________
>     postgis-users mailing list
>     postgis-users at postgis.refractions.net
>     <mailto: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


-- 
Alessandro Candini
MEEO S.r.l.
Via Saragat 9
I-44122 Ferrara, Italy
Tel: +39 0532 1861501
Fax: +39 0532 1861637
http://www.meeo.it

========================================
"ATTENZIONE:le informazioni contenute in questo messaggio sono
da considerarsi confidenziali ed il loro utilizzo è riservato unicamente
al destinatario sopra indicato. Chi dovesse ricevere questo messaggio
per errore è tenuto ad informare il mittente ed a rimuoverlo
definitivamente da ogni supporto elettronico o cartaceo."

"WARNING:This message contains confidential and/or proprietary
information which may be subject to privilege or immunity and which
is intended for use of its addressee only. Should you receive this
message in error, you are kindly requested to inform the sender and
to definitively remove it from any paper or electronic format."

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


More information about the postgis-users mailing list