<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
<p class="MsoNormal" style="line-height:12.75pt">Hi Bret,<o:p></o:p></p><p class="MsoNormal" style="line-height:12.75pt"><br></p>

<p class="MsoNormal" style="line-height:12.75pt">Thanks for your help. I am now
able to update lat and long column as explained by you. <o:p></o:p></p>

<p class="MsoNormal" style="line-height:12.75pt">Sometimes I attributes like ‘0002N/5155’
in geocode column. Now in the lat_dms column the attribute should be ‘000200’
and ‘-515500’in long_dms column. But how do I get the ‘N’ in ‘lat’ part recognized
in query so that it is not placed as ‘-000020’ but as positive coordinate.
Also, the number of character will get changes in ‘lat’ it will now be 1 to 5 character
and ‘7 to 10’ in long.<o:p></o:p></p>

<p class="MsoNormal" style="line-height:12.75pt">Is there a possibility of having
one query that takes care of ‘geocode’ in 4 x 4 format as well as 5 x 4 ----format
with fifth word as N?<o:p></o:p></p>

<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal">+-----------------------------+<o:p></o:p></p>

<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal">| Lat_dms | lat_dms |<o:p></o:p></p>

<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal">-------------------------------<o:p></o:p></p>

<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal">| -232900  | -472700 |<o:p></o:p></p>

<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal">-------------------------------<o:p></o:p></p>

<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal">| 000200 <span style="mso-spacerun:yes">  </span>| -515500 |<o:p></o:p></p>

<p class="MsoNormal" style="line-height:12.75pt">+-----------------------------+<o:p></o:p></p><p class="MsoNormal" style="line-height:12.75pt"><br></p>

<p class="MsoNormal" style="line-height:12.75pt">Thanks for your help.. actually I
am novice to GIS and postgres world….<o:p></o:p></p><p class="MsoNormal" style="line-height:12.75pt"><br></p>

<p class="MsoNormal" style="line-height:12.75pt">Thanks,<o:p></o:p></p>

<p class="MsoNormal" style="line-height:12.75pt">YJ<o:p></o:p></p><br><div><hr id="stopSpelling">Date: Wed, 13 Jul 2011 10:46:17 -0700<br>From: pcreso@pcreso.com<br>Subject: RE: [postgis-users] converting to lat long<br>To: yaminijsingh@live.com<br>CC: postgis-users@postgis.refractions.net<br><br><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit"><br>Glad it helped.<br><br>You can do that, but that is simply using Postgres columns, you do not require Postgis & geometry capabilities to do that. I recommend you avoid upper case characters in table & column names, otherwise you'll need to quote them.<br><br><span style="font-style:italic">alter table <tablename> add column lat_dms int;</span><br style="font-style:italic"><span style="font-style:italic">update <tablename> set lat_dms=('-'||substr(geocode,1,4)||'00')::int;</span><br><br>The "||" operator is a string concatenation operator, so the sql starts with '-', appends the <br>specified substring from geocode, appends two more zeros, then converts the whole thing to an integer. If the columns you will be comparing them with are strings, not numbers, then create these two columns as the same datatype & don't do the "::int"
 conversion.<br><br>Then do the same for lon - but remember to substr(geocode,6,4) instead <br>(or combine the sqls to do both in a single statement).<br><br>Note that my previous example creating a Postgis geometry assumed that 1234 was decimal degrees (12.34deg). So if the numbers reflect degrees & minutes (12deg 34min) then the result is incorrect. You should substring the deg & min separately, convert both to numeric, divide the minute value by 60 then add them to get the decimal degree value.<br><br><br>Cheers,<br><br>Brent<br><br><br><blockquote style="margin-left:5px;padding-left:5px"><div id="ecxyiv159434206"><div dir="ltr"><div></div>                                     </div> 
</div></blockquote></td></tr></tbody></table></div>                                     </div></body>
</html>