A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Map co-ordinates conversion



 
 
Thread Tools Display Modes
  #1  
Old September 26th, 2009, 09:28 AM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.newusers
Bill R[_5_]
external usenet poster
 
Posts: 31
Default Map co-ordinates conversion

The following converts latitude co-ordinates in cell A3 from NN:NN:NN and
N:NN:NN format to N.NN format. (A similar formulae does the same for
longitude co-ordinates.)

=IF(RIGHT(A3,1)="W",IF(MID(A3,2,1)=":",(LEFT(A3,1) )+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60))*-1,IF(MID(A3,2,1)=":",(LEFT(A3,1))+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60)))

It is complicated as it needs to accommodate source information in degrees
in NN and N format (others are given in NN format) and, of course, the
output to be both positive (east of Greenwich and north of the equator) and
negative. Is there a better (shorter) formulae that will do the same job?

Thanks.

Bill R


  #2  
Old September 26th, 2009, 11:12 AM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.newusers
macropod[_2_]
external usenet poster
 
Posts: 2,402
Default Map co-ordinates conversion

Hi Bill,

Assuming your input in A3 is, say W127:30:27, you can get the decimal representaion by:
=RIGHT(A3,LEN(A3)-1)*24*IF(LEFT(A3,1)="W",-1,1)

--
Cheers
macropod
[Microsoft MVP - Word]


"Bill R" wrote in message ...
The following converts latitude co-ordinates in cell A3 from NN:NN:NN and N:NN:NN format to N.NN format. (A similar formulae does
the same for longitude co-ordinates.)

=IF(RIGHT(A3,1)="W",IF(MID(A3,2,1)=":",(LEFT(A3,1) )+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60))*-1,IF(MID(A3,2,1)=":",(LEFT(A3,1))+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60)))

It is complicated as it needs to accommodate source information in degrees in NN and N format (others are given in NN format) and,
of course, the output to be both positive (east of Greenwich and north of the equator) and negative. Is there a better (shorter)
formulae that will do the same job?

Thanks.

Bill R


  #3  
Old September 26th, 2009, 12:04 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.newusers
Ron Rosenfeld
external usenet poster
 
Posts: 3,719
Default Map co-ordinates conversion

On Sat, 26 Sep 2009 09:28:29 +0100, "Bill R"
wrote:

The following converts latitude co-ordinates in cell A3 from NN:NN:NN and
N:NN:NN format to N.NN format. (A similar formulae does the same for
longitude co-ordinates.)

=IF(RIGHT(A3,1)="W",IF(MID(A3,2,1)=":",(LEFT(A3,1 ))+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60))*-1,IF(MID(A3,2,1)=":",(LEFT(A3,1))+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60)))

It is complicated as it needs to accommodate source information in degrees
in NN and N format (others are given in NN format) and, of course, the
output to be both positive (east of Greenwich and north of the equator) and
negative. Is there a better (shorter) formulae that will do the same job?

Thanks.

Bill R


To convert coordinates in "degrees" to decimal, merely multiply by 24 and
format the results as Number (or General) with the required number of decimal
places.

So, with the proper format for the cell:

=IF(ISERR(FIND(":",A1)),A1,IF(RIGHT(A1)="S",-1,1)*LEFT(A1,LEN(A1)-1)*24)

This formula has no error checking for blank cells or improperly formatted
entries (e.g. no N or S at the end). That could certainly be easily added.

--ron
  #4  
Old September 26th, 2009, 12:08 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.newusers
Bill R[_5_]
external usenet poster
 
Posts: 31
Default Map co-ordinates conversion

Thanks,

NSEW is usually after the co-ordinates so I just swapped the RIGHT and LEFT
and it worked OK. BTW, when using NSEW the number can only go up to 90 (or
should that be 89.999...?)

That's certainly compacted an awful looking formulae.

Bill R

"macropod" wrote in message
...
Hi Bill,

Assuming your input in A3 is, say W127:30:27, you can get the decimal
representaion by:
=RIGHT(A3,LEN(A3)-1)*24*IF(LEFT(A3,1)="W",-1,1)

--
Cheers
macropod
[Microsoft MVP - Word]


"Bill R" wrote in message
...
The following converts latitude co-ordinates in cell A3 from NN:NN:NN and
N:NN:NN format to N.NN format. (A similar formulae does the same for
longitude co-ordinates.)

=IF(RIGHT(A3,1)="W",IF(MID(A3,2,1)=":",(LEFT(A3,1) )+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60))*-1,IF(MID(A3,2,1)=":",(LEFT(A3,1))+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60)))

It is complicated as it needs to accommodate source information in
degrees in NN and N format (others are given in NN format) and, of
course, the output to be both positive (east of Greenwich and north of
the equator) and negative. Is there a better (shorter) formulae that
will do the same job?

Thanks.

Bill R




  #5  
Old September 26th, 2009, 02:31 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.newusers
Bill R[_5_]
external usenet poster
 
Posts: 31
Default Map co-ordinates conversion

Oops.

Of course you can go up 180 (or is that 179.99...) degrees east or west to
make a complete circle. It's north or south that only goes up to 90 degrees
because the other 180 degrees is on the other side.

Apologies.

Bill R

Thanks,

NSEW is usually after the co-ordinates so I just swapped the RIGHT and
LEFT and it worked OK. BTW, when using NSEW the number can only go up to
90 (or should that be 89.999...?)

That's certainly compacted an awful looking formulae.

Bill R

"macropod" wrote in message
...
Hi Bill,

Assuming your input in A3 is, say W127:30:27, you can get the decimal
representaion by:
=RIGHT(A3,LEN(A3)-1)*24*IF(LEFT(A3,1)="W",-1,1)

--
Cheers
macropod
[Microsoft MVP - Word]


"Bill R" wrote in message
...
The following converts latitude co-ordinates in cell A3 from NN:NN:NN
and N:NN:NN format to N.NN format. (A similar formulae does the same
for longitude co-ordinates.)

=IF(RIGHT(A3,1)="W",IF(MID(A3,2,1)=":",(LEFT(A3,1) )+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60))*-1,IF(MID(A3,2,1)=":",(LEFT(A3,1))+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60)))

It is complicated as it needs to accommodate source information in
degrees in NN and N format (others are given in NN format) and, of
course, the output to be both positive (east of Greenwich and north of
the equator) and negative. Is there a better (shorter) formulae that
will do the same job?

Thanks.

Bill R






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:41 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.