<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<STYLE type=text/css>DIV {
MARGIN: 0px
}
</STYLE>
<META content="MSHTML 6.00.6000.16481" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=395575820-19072007><FONT face=Arial
color=#0000ff size=2>Alan,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=395575820-19072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=395575820-19072007><FONT face=Arial
color=#0000ff size=2>Sorry I didn't see this email until now. Still not
quite clear your question, so hopefully the explanation below will
help.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=395575820-19072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=395575820-19072007><FONT face=Arial
color=#0000ff size=2>1) You can either statically store the values in the table
doing</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=395575820-19072007> <FONT
face=Arial color=#0000ff size=2>UPDATE bus_stops1 SET xcoord =
x(transform(east_north, 4326)), ycoord =
y(transform(east_north,4326))</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=395575820-19072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=395575820-19072007><FONT face=Arial
color=#0000ff size=2>where xcoord and ycoord are numeric or float fields you
create to store the values.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=395575820-19072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=395575820-19072007><FONT face=Arial
color=#0000ff size=2>Then for inserting you would do</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=395575820-19072007>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>INSERT INTO bus_stops1(east_north<SPAN
class=395575820-19072007>, xcoord, ycoord</SPAN>)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>
values(transform(setsrid(makepoint([lon],[lat]), 4326), 27700)<SPAN
class=395575820-19072007>, [lon], [lat]</SPAN>)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff size=2>where [lon] and
[lat] are the x and y coords you get from google map.</FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff size=2>2) Or
alternatively as I mentioned you would create a view and for most purposes
except for inserting ignore your original table. This is a bit slower, but
I don't think significantly slower.</FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff size=2>---Now some
explanation</FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff size=2>x is a function
that returns the x coordinate of a postgis point, y is a function that returns
the y coordinate of a postgis point geometry</FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff size=2>So what I am
doing here is first transforming to WGS 84 and then getting the x and y.
Since the dimensions of the transformed geometry are in degrees for 4326, then
the x and y returned will be in degrees as well.</FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff size=2>Hope that
helps,</FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><SPAN
class=395575820-19072007><FONT face=Arial color=#0000ff
size=2>Regina</FONT></SPAN></SPAN></DIV></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of </B>Alan
Cunnane<BR><B>Sent:</B> Wednesday, July 18, 2007 4:49 PM<BR><B>To:</B> PostGIS
Users Discussion<BR><B>Subject:</B> Re: [postgis-users] Transforming
Coordinates<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV
style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<DIV
style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman,new york,times,serif">What
I need to do is create a new column in the bus_stops1 table with x and x
coordinates. If I use your suggestion below to transform the column east_north
to x and y wont both the new X and Y columns be the same value as it is the same
query?<BR><BR><BR>
<DIV
style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman,new york,times,serif">-----
Original Message ----<BR>From: "Obe, Regina"
<robe.dnd@cityofboston.gov><BR>To: PostGIS Users Discussion
<postgis-users@postgis.refractions.net><BR>Sent: Wednesday, 18 July, 2007
9:38:29 PM<BR>Subject: RE: [postgis-users] Transforming Coordinates<BR><BR>
<STYLE type=text/css>DIV {
MARGIN: 0px
}
</STYLE>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>Not quite sure what you are asking. For this kind of
stuff, I usually create a view and use that for google maps if I have a lot of
apps that need it or you could alternatively just write the sql of the view each
time you need it. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>Would be something like this</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>CREATE VIEW vwbusstopsgoogle As</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2> select x(transform(east_north, 4326)) As
lon, y(transform(east_north,4326)) As lat, [other fields you need go
here]</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=541583120-18072007> <FONT
face=Arial color=#0000ff size=2>FROM bus_stops1</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>The to use</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>SELECT lon, lat from vwbusstopsgoogle</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>To transform back it would be</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>INSERT INTO bus_stops1(east_north)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>
values(transform(setsrid(makepoint([lon],[lat]), 4326),
27700))</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2>WHERE [lon], [lat] you replace with the x y you get from
google.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=541583120-18072007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of </B>Alan
Cunnane<BR><B>Sent:</B> Wednesday, July 18, 2007 4:28 PM<BR><B>To:</B> PostGIS
Users Discussion<BR><B>Subject:</B> [postgis-users] Transforming
Coordinates<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman,new york,times,serif">
<DIV>Hi guys<BR><BR>I have a table with easting northing coordinates and these
points in a geom column. I have 15,000 points with an easting and a northing
(brittish national grid) and created the geom column using these
commands:<BR><BR>SELECT AddGeometryColumn( 'bus_stops1', 'east_north', 27700,
'POINT', 2 );<BR>UPDATE bus_stops1 SET east_north = PointFromText('POINT(' ||
easting || ' ' || northing || ')',27700);<BR><BR>The table looks like this at
the moment:<BR><BR> easting | northing
|
east_north<BR>---------+----------+----------------------------------------------------<BR>
226965 | 676038 |
0101000020346C000000000000A8B40B41000000008CA12441<BR> 226761
| 675945 |
0101000020346C00000000000048AE0B4100000000D2A02441<BR> 226696
| 675893 |
0101000020346C00000000000040AC0B41000000006AA02441<BR> 226473
| 675777 |
0101000020346C00000000000048A50B4100000000829F2441<BR> 226465
| 675731 |
0101000020346C00000000000008A50B4100000000269F2441<BR> 226614
| 675611 |
0101000020346C000000000000B0A90B4100000000369E2441<BR> 226603
| 675605 |
0101000020346C00000000000058A90B41000000002A9E2441<BR> 226869
| 675621 |
0101000020346C000000000000A8B10B41000000004A9E2441<BR> 226883
| 675630 |
0101000020346C00000000000018B20B41000000005C9E2441<BR> 226544
| 674911 |
0101000020346C00000000000080A70B4100000000BE982441<BR> 226767
| 675293 |
0101000020346C00000000000078AE0B4100000000BA9B2441<BR> 226767
| 675303 |
0101000020346C00000000000078AE0B4100000000CE9B2441<BR><BR><BR>Now what I want to
be able to do is to add another column or two columns with X and Y values in WGS
or the standard X and Y coordinates for entry into google maps. I dont want to
transform the east_north column so that I get another long string as is shown
above as I cannot then integrate them into google maps. Can this be done using
PostgreSQL?<BR><BR>Also I would like to do the opposite too. Take x and y
coordinates from google maps and transform them to easting northing as above.
Thanks for your help again<BR><BR></DIV></DIV><BR>
<HR SIZE=1>
Yahoo! Mail is the world's favourite email. Don't settle for less, <A
href="http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html"
target=_blank rel=nofollow>sign up for your free account today</A>.
<P></P>
<HR SIZE=1>
<P></P>
<P><STRONG>The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure pursuant to
Massachusetts law. It is intended solely for the addressee. If you received this
in error, please contact the sender and delete the material from any computer.
</STRONG></P>
<DIV>_______________________________________________<BR>postgis-users mailing
list<BR>postgis-users@postgis.refractions.net<BR><A
href="http://postgis.refractions.net/mailman/listinfo/postgis-users"
target=_blank>http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR></DIV></DIV><BR></DIV></DIV><BR>
<HR SIZE=1>
Yahoo! Mail is the world's favourite email. Don't settle for less, <A
href="http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html">sign
up for your free account today</A>.</BODY></HTML>