[postgis-users] converting to lat long

James David Smith james.david.smith at gmail.com
Tue Jul 12 06:12:57 PDT 2011


YJ,

I'm a beginner, so take with a pinch of salt, but first I'd question
why you want/need to separate the latitude & longitude?

I would keep them together and store them as a point in a new column.
First create a column to store the Lat & Long in with something like
this:

SYNTAX:    SELECT AddGeometryColumn(<table_name>, <column_name>,
<srid>, <type>, <dimension>)
EXAMPLE:  SELECT AddGeometryColumn('parks', 'park_geom','4326', 'POINT', 2 );

Then you want to populate that column, with the existing data from
your geocode column. Using something like this:

UPDATE tablename
SET latlongcolumn = ST_GeomFromText('geocode', 4326)

I guess that there is a way to pull out the lat and long into seperate
columns, but I don't know how to do that I'm afraid.

Cheers

James





On 12 July 2011 13:58, Yamini Singh <yaminijsingh at live.com> wrote:
> Hi All,
>
> I have a column 'geocode' in a table which has attributes like 2329/4727 now
> I would like to convert these attributes in another column to 'lat' and
> 'long'. For example, 'Lat' column will have attribute '23.29' and 'long'
> column will have attribute  '47.27'.
>
> Is there a way through which this can be converted automatically by a query
> or so.
>
> Looking fwd..
>
>
>
> Thanks
>
> YJ
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>



More information about the postgis-users mailing list