[postgis-users] Using PostGIS for latitude & longitude

Tim-Hinnerk Heuer th.heuer at gmail.com
Mon Dec 24 16:22:05 PST 2012


Merry Xmas everyone.

I believe you can also use ST_GeomFromText('POINT(123, 456)', 2163) to get
back a geometry.

Regards,
Tim
On Dec 25, 2012 10:30 AM, "Stephen Woodbridge" <woodbri at swoodbridge.com>
wrote:

> Also, be aware that PostGIS expects coordinates in X-Y order which means
> for need to enter lat, lon as (long, lat) to correspond to (X, Y).
>
> -Steve
>
> PS: Merry Christmas Brent and everyone else!
>
> On 12/24/2012 3:54 PM, pcreso at pcreso.com wrote:
>
>> Hi Neville,
>>
>> Merry Christmas (it already is here in NZ :-)
>>
>> You are passing a string - 'POINT(33.911404 -116.768347)' - not a
>> geometry in your query hence the error message that ST_SetSRID() doesn't
>> know what the first parameter is
>>
>> Instead of:
>>
>> select state from zipcode where DISTANCE(column2,
>> ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000;
>>
>> try:
>>
>> select state from zipcode where DISTANCE(column2,
>> ST_SetSRID(ST_MAKEPOINT(33.**911404 -116.768347), 2163)) < 8000;
>>
>>
>> Cheers,
>>
>>    Brent
>>
>>
>> --- On *Tue, 12/25/12, nevillekb /<nevillekb at gmail.com>/* wrote:
>>
>>
>>     From: nevillekb <nevillekb at gmail.com>
>>     Subject: Re: [postgis-users] Using PostGIS for latitude & longitude
>>     To: postgis-users at postgis.**refractions.net<postgis-users at postgis.refractions.net>
>>     Date: Tuesday, December 25, 2012, 1:32 AM
>>
>>     Hi,
>>
>>     So i created a table named zipcode with the following columns
>>
>>     Id
>>     State
>>     Zip
>>     Latitude
>>     Longitude
>>     column1
>>     column2
>>
>>     columns named column1 and column2 are the 2 geometry columns i have
>>     created
>>     to store the lat and long in 2 formats -SRID 4269 (Lat/Lon) and SRID
>>     2163
>>     (US National Atlas – meters).
>>
>>     Then i execute the following query to populate both the columns with
>>     the lat
>>     and lon data
>>
>>     UPDATE zipcode SET column1 =
>>     ST_SetSRID(ST_MakePoint("**longitude","latitude"),4269), column2 =
>>     ST_Transform(ST_SetSRID(ST_**MakePoint("longitude","**
>> latitude"),4269),
>>     2163);
>>
>>     Everything has worked fine till now, but now when i try to execute the
>>     following query to show all records that are within 5 miles of a
>>     given point
>>     i get an error.
>>
>>     Query:
>>
>>     select state from zipcode where DISTANCE(column2,
>>     ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000;
>>
>>     Error Generated:
>>
>>     WARNING  ] select state from zipcode where DISTANCE(column2,
>>     ST_SetSRID('POINT(33.911404 -116.768347)', 2163)) < 8000
>>                  ERROR:  function st_setsrid(unknown, integer) is not
>> unique
>>                  LINE 1: select state from zipcode where DISTANCE(column2,
>>     ST_SetSRID...
>>                                            ^
>>                  HINT:  Could not choose a best candidate function. You
>>     might
>>     need to add explicit type casts.
>>
>>     Can someone help me out as to where am i going wrong in the above
>>     query??
>>
>>     Thanks
>>
>>
>>
>>     --
>>     View this message in context:
>>     http://postgis.17.n6.nabble.**com/Using-PostGIS-for-**
>> latitude-longitude-**tp5002097p5002125.html<http://postgis.17.n6.nabble.com/Using-PostGIS-for-latitude-longitude-tp5002097p5002125.html>
>>     Sent from the PostGIS - User mailing list archive at Nabble.com.
>>     ______________________________**_________________
>>     postgis-users mailing list
>>     postgis-users at lists.osgeo.org
>>     http://lists.osgeo.org/cgi-**bin/mailman/listinfo/postgis-**users<http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users>
>>
>>
>>
>> ______________________________**_________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> http://lists.osgeo.org/cgi-**bin/mailman/listinfo/postgis-**users<http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users>
>>
>>
> ______________________________**_________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-**bin/mailman/listinfo/postgis-**users<http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121225/6b1aa243/attachment.html>


More information about the postgis-users mailing list