<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Shaun,<br><br>You add a geometry column to the table, then run an update sql to populate it.<br><br>eg, assuming your table is called mytable, located in the public schema, & you want to create a two dimensional point with lat/long coordinates (EPSG:4326) called "geom":<br><br>select ST_AddGeometryColumn('public','mytable','geom','4326','POINT',2);<br><br>then update this table to populate the new geometry column from your x & Y columns (called lon & lat) set to EPSG:4326 coordinates:<br><br>update mytable set geom = ST_Setsrid(ST_Makepoint(lon, lat),4326);<br><br>Note that if you are doing any spatial queries (such as point in polygon, etc), that you should also add a spatial index to this column.<br><br><br>HTH,<br><br>   Brent Wood<br><br><br>--- On <b>Sun, 4/29/12, Shaun Langley <i><shaunlangley@gmail.com></i></b>
 wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Shaun Langley <shaunlangley@gmail.com><br>Subject: [postgis-users] Adding geometry to an existing table<br>To: postgis-users@postgis.refractions.net<br>Date: Sunday, April 29, 2012, 6:34 AM<br><br><div id="yiv1752595953"><div><div style="margin:0px;font-family:Verdana;font-size:12px;">I got myself into quite a mess and I'm hoping somebody out there can help me. I've created a database that includes in the range of 150 million records so far and I need to make a change to it. I have lat lon fields stored as strings in separate columns. What I would like to do is to take these 2 columns and created geometry column that combines both fields. I don't think there's a global function that will allow me to do this, but is there a way for me to use string formatting to do this easily?</div><div
 style="margin:0px;font-family:Verdana;font-size:12px;"><br></div><div style="margin:0px;font-family:Verdana;font-size:12px;">Regards, </div><div style="margin:0px;font-family:Verdana;font-size:12px;"> Shaun Langley</div></div></div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>postgis-users mailing list<br><a ymailto="mailto:postgis-users@postgis.refractions.net" href="/mc/compose?to=postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></div></blockquote></td></tr></table>