Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Converting LAt Long to UTM
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Karl Kristian Markman  
View profile  
 More options Oct 9 2012, 6:40 am
From: Karl Kristian Markman <karlkristian.mark...@gmail.com>
Date: Tue, 9 Oct 2012 03:40:16 -0700 (PDT)
Local: Tues, Oct 9 2012 6:40 am
Subject: Converting LAt Long to UTM

Hi

I am currently in the process with making an app that shall show the
loaction retrived from the GPS sensor and displying the position in UTM
format (WGS83 datum).

Is there a way to get the location info from the GPS as UTM?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rudolf Hornig  
View profile  
 More options Oct 9 2012, 8:17 am
From: Rudolf Hornig <rudolf.hor...@gmail.com>
Date: Tue, 9 Oct 2012 05:17:12 -0700 (PDT)
Local: Tues, Oct 9 2012 8:17 am
Subject: Re: Converting LAt Long to UTM

No. Location is provides as lat/lon in WGS84. You have to convert that to
UTM.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl Kristian Markman  
View profile  
 More options Oct 9 2012, 3:16 pm
From: Karl Kristian Markman <karlkristian.mark...@gmail.com>
Date: Tue, 9 Oct 2012 12:16:20 -0700 (PDT)
Local: Tues, Oct 9 2012 3:16 pm
Subject: Re: Converting LAt Long to UTM

I figured as much.

I hav found the forumla but Im not sure how to use the formula in code. I
mean do I just put the numbers and calculations in or do I need a special
syntax for things like sinus and cosinus?

Here is link to formula : Lat long to UTM<http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl Kristian Markman  
View profile  
 More options Oct 10 2012, 2:03 pm
From: Karl Kristian Markman <karlkristian.mark...@gmail.com>
Date: Wed, 10 Oct 2012 11:03:48 -0700 (PDT)
Local: Wed, Oct 10 2012 2:03 pm
Subject: Re: Converting LAt Long to UTM

Can someone pleas tell me how to get numbers in power ?

Like this (syntax used in Excel): 45^(3/2) ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bob  
View profile  
 More options Oct 10 2012, 5:57 pm
From: bob <b...@coolfone.comze.com>
Date: Wed, 10 Oct 2012 14:57:53 -0700 (PDT)
Local: Wed, Oct 10 2012 5:57 pm
Subject: Re: Converting LAt Long to UTM

Math.pow(45.0, 1.5);

On Wednesday, October 10, 2012 1:03:48 PM UTC-5, Karl Kristian Markman
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew  
View profile  
 More options Oct 10 2012, 8:12 pm
From: Lew <lewbl...@gmail.com>
Date: Wed, 10 Oct 2012 17:12:50 -0700 (PDT)
Local: Wed, Oct 10 2012 8:12 pm
Subject: Re: Converting LAt Long to UTM

Karl Kristian Markman wrote:
> I figured as much.

> I hav found the forumla but Im not sure how to use the formula in code. I
> mean do I just put the numbers and calculations in or do I need a special
> syntax for things like sinus and cosinus?

It's a good idea to know the Java API. To this end, bookmark the API docs,
which
for Android are at
http://developer.android.com/reference/packages.html

You should be especially familiar with the java.lang and java.util packages
http://developer.android.com/reference/java/lang/package-summary.html
http://developer.android.com/reference/java/util/package-summary.html

For sine and cosine you want:
http://developer.android.com/reference/java/lang/Math.html

It's kind of hard to program for Android if you don't know Java.
http://docs.oracle.com/javase/tutorial/

--
Lew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl Kristian Markman  
View profile  
 More options Oct 11 2012, 5:48 am
From: Karl Kristian Markman <karlkristian.mark...@gmail.com>
Date: Thu, 11 Oct 2012 02:48:26 -0700 (PDT)
Local: Thurs, Oct 11 2012 5:48 am
Subject: Re: Converting LAt Long to UTM

Thanks Lew. I have figured it out (after reading the API docs ++.)

So here is the code I use to transform the Lat long to UTM ( in case anyone
else wouders..)

[code]

public void convert (){

                double a = 6378137;
        double b = 6356752.3142;

                e = Math.sqrt(1-Math.pow(b,2)/Math.pow(a, 2));  // a and b
are constants.
e2 = e*e/(1-(e*e));
n =(a-b)/(a+b);        
 A0 =  a*(1 - n + (5/4)*(Math.pow(n,2) - Math.pow(n,3)) +
(81/64)*(Math.pow(n,4) - Math.pow(n,5)));
  B0 =(3*a*n/2)*(1 - n - (7*n*n/8)*(1-n) + (55/64)*(Math.pow(n,
4)-Math.pow(n, 5)));
C0 =(15*a*n*n/16)*(1 - n +(3*n*n/4)*(1-n));
D0 =(35*a*Math.pow(n, 3)/48)*(1 - n + 11*n*n/16);
E0 =(315*a*Math.pow(n,4)/51)*(1-n);
 zone = (int) (31 + (lngdeg/6));
 double pi = 6* zone -183;
double pii = (lngdeg-pi)*Math.PI/180;
double rho1 = (1-(e*e) * (Math.sin(lat)*( Math.sin(lat))));
rho = a * (1-e*e)/ Math.pow(rho1, (3/2));
nu = a/(Math.pow((1-(e*e *(Math.sin(lat))*(Math.sin(lat)))), (1/2)));
S  = A0* lat - B0 * Math.sin(2*lat) + C0 * Math.sin(4*lat) - D0 *
Math.sin(6*lat) + E0 * Math.sin(8*lat);
double Ki = S * knu;
double Kii = knu * nu *Math.sin(lat)*Math.cos(lat)/2;
double Kiii = (knu * nu
*Math.sin(lat)*Math.pow(Math.cos(lat),3)/24)*(5-Math.pow(Math.tan(lat),2)+9 *Math.pow(e2,2)*Math.pow(Math.cos(lat),2)+4*Math.pow(e2
,2)*Math.pow(Math.cos(lat),4));
double Kiv = knu * nu *Math.cos(lat);
double Kv = knu *
Math.pow(Math.cos(lat),3)*(nu/6)*(1-Math.pow(Math.tan(lat),2)+e2*Math.pow(M ath.cos(lat),2));

double UTMni = (Ki+Kii*Math.pow(pii, 2)+ Kiii * Math.pow(pii,4));
double UTMei = 500000 + (Kiv*pii + Kv * Math.pow(pii, 3));
 UTMn = (int) UTMni;
UTMe = (int) UTMei;

}

[/code]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew  
View profile  
 More options Oct 11 2012, 1:53 pm
From: Lew <lewbl...@gmail.com>
Date: Thu, 11 Oct 2012 10:53:22 -0700 (PDT)
Local: Thurs, Oct 11 2012 1:53 pm
Subject: Re: Converting LAt Long to UTM

Karl Kristian Markman wrote:
> So here is the code I use to transform the Lat long to UTM ( in case
> anyone else wouders..)

> [code]

> public void convert (){

>                 double a = 6378137;

Strictly speaking, you should use a double constant to initialize a double
variable.
Fortunately Java does the conversion for you.

>         double b = 6356752.3142;

>                 e = Math.sqrt(1-Math.pow(b,2)/Math.pow(a, 2));  // a and b
> are constants.

'a' and 'b' are not constants in the Java sense unless they're declared
'final'.

'Math.pow()' for squares, really? Why?

> e2 = e*e/(1-(e*e));

Yet here you use the multiplication idiom for squares. Why the difference?

OMFG, dude! You are just all over the place with this. Variables out of
nowhere,
terse obscure names, varying idioms for the same kinds of calculations,
utter
lack of comments or whitespace, except for the exorbitant indentation,
variable names
that imply different values, and the one and only comment you include tells
nothing
except for a falsehood that isn't relevant anyway, and would have been
self-explanatory
in code if the variables had been constants.

I gather this code is meant neither to be re-used, shared nor maintained.

--
Lew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl Kristian Markman  
View profile  
 More options Oct 12 2012, 3:37 am
From: Karl Kristian Markman <karlkristian.mark...@gmail.com>
Date: Fri, 12 Oct 2012 00:37:42 -0700 (PDT)
Local: Fri, Oct 12 2012 3:37 am
Subject: Re: Converting LAt Long to UTM

Have you see the formulas for converting Lew?

Yes i agree I have not been good with comments. If its any constalation I
will update the code mow that its working....


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl Kristian Markman  
View profile  
 More options Oct 12 2012, 4:05 am
From: Karl Kristian Markman <karlkristian.mark...@gmail.com>
Date: Fri, 12 Oct 2012 01:05:22 -0700 (PDT)
Local: Fri, Oct 12 2012 4:05 am
Subject: Re: Converting LAt Long to UTM

Lew is this more what you are looking for??

Also I have a link to the forumla I used<http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm>

public void onLocationChanged(Location location) {

  lat = Math.toRadians(location.getLatitude()); // Latitude in radians
  lng = Math.toRadians(location.getLongitude()); // Longitude in radians
  lngdeg = location.getLongitude();  // Latitude in "normal" form. dd.dd
 convert();

     pos.setText(zone + "\t"+ UTMn +"\n \t\t\t" +UTMe );

  }

  public void convert(){ // konverter fra Lat /Long til UTM (WGS84 / NAD84)
  public final double knu = 0.9996;  // scale along central meridian of zone
  public final double a = 6378137;   //Equatorial radius in meters
  public final double b = 6356752.3142; // Polar radius in meters

e = Math.sqrt(1-(b*b)/(a*a)); // e = the eccenticity of the earth's
elliptical cross-section
e2 = e*e/(1-(e*e)); // The quantile e' only occurs in even powers
n =(a-b)/(a+b);
  zone = (int) (31 + (lngdeg/6)); // Calculating UTM zone using Longetude
in dd.dd form as supplied by the GPS
 double pi = 6* zone -183; // Central meridian of zone
double pii = (lngdeg-pi)*Math.PI/180; //Differance between Longitude and
central meridian of zone
 rho = a * (1-e*e)/ Math.pow((1-(e*e) * (Math.sin(lat)*( Math.sin(lat)))),
(3/2)); // The radius of the curvature of the earth in meridian plane
 nu = a/(Math.pow((1-(e*e *(Math.sin(lat))*(Math.sin(lat)))), (1/2)));
//The radius of the curvature of the earth perpendicular to the meridian
plane
 /*
 * A0 - E0 is used for calclulating the Meridinol arc through the given
point (lat long)
 * The distance from the earth's surface form the equator. All angles are
in radians
 *
 */
 A0 =  a*(1 - n + (5/4)*(Math.pow(n,2) - Math.pow(n,3)) +
(81/64)*(Math.pow(n,4) - Math.pow(n,5)));
  B0 =(3*a*n/2)*(1 - n - (7*n*n/8)*(1-n) + (55/64)*(Math.pow(n,
4)-Math.pow(n, 5)));
C0 =(15*a*n*n/16)*(1 - n +(3*n*n/4)*(1-n));
D0 =(35*a*Math.pow(n, 3)/48)*(1 - n + 11*n*n/16);
E0 =(315*a*Math.pow(n,4)/51)*(1-n);
 // Calculation of the Meridional Arc
S  = A0* lat - B0 * Math.sin(2*lat) + C0 * Math.sin(4*lat) - D0 *
Math.sin(6*lat) + E0 * Math.sin(8*lat);
 /*
 * y = northing = Ki+ Kiip^2 + Kiip^4
 *
 *
 */
 double Ki = S * knu;
double Kii = knu * nu *Math.sin(lat)*Math.cos(lat)/2;
double Kiii = (knu * nu
*Math.sin(lat)*Math.pow(Math.cos(lat),3)/24)*(5-Math.pow(Math.tan(lat),2)+9 *Math.pow(e2,2)*Math.pow(Math.cos(lat),2)+4*Math.pow(e2
,2)*Math.pow(Math.cos(lat),4));
 /*
 *  x = easting = Kivpii + Kvpii^3 +
 */
double Kiv = knu * nu *Math.cos(lat);
double Kv = knu *
Math.pow(Math.cos(lat),3)*(nu/6)*(1-Math.pow(Math.tan(lat),2)+e2*Math.pow(M ath.cos(lat),2));

double UTMni = (Ki+Kii*Math.pow(pii, 2)+ Kiii * Math.pow(pii,4));// Northing
double UTMei = 500000 + (Kiv*pii + Kv * Math.pow(pii, 3));  //Easting is
relative to the central meridain. Forconvetional UTM Easting add 5000000
meters to x
 UTMn = (int) UTMni; // Northing, rounded to closest integer
UTMe = (int) UTMei; // Easting, rounded to closest integer
  }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew  
View profile  
 More options Oct 12 2012, 5:50 pm
From: Lew <lewbl...@gmail.com>
Date: Fri, 12 Oct 2012 14:50:47 -0700 (PDT)
Local: Fri, Oct 12 2012 5:50 pm
Subject: Re: Converting LAt Long to UTM

Karl Kristian Markman wrote:
> Lew is this more what you are looking for??

Nope. I was talking about the conversion of 'int' to 'double', which does
not involve any formulas.

>   public final double a = 6378137;   //Equatorial radius in meters

(Do not use TAB characters to indent code in your posts. Use 2 to 4 spaces
per level.)

Java conveniently does the conversion for you. However, you should be aware
of it.

--
Lew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl Kristian Markman  
View profile  
 More options Oct 19 2012, 7:32 am
From: Karl Kristian Markman <karlkristian.mark...@gmail.com>
Date: Fri, 19 Oct 2012 04:32:23 -0700 (PDT)
Local: Fri, Oct 19 2012 7:32 am
Subject: Re: Converting LAt Long to UTM

Sorry for the TAB usage but I just copy/past from eclipse..

I have one more problem here. The conversion sort of works but I miss the
target by about 200 meters West. I have figured it out to bee this line
that screws everything up.:

nu = a/(Math.pow((1-(e*e* Math.sin(lat)*Math.sin(lat))), (1/2));

As it is written in plain language:

nu = a/(1-e^2sin(lat)^2)^1/2

When I enter this in to excel I get 6394567 and from my app I get 6378922.
This follows through on every calculation done after.

I saw one place (in Java code though) where they used
Math.pow(Math.sin(lat),(1/2.0)) for setting odd powers.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl Kristian Markman  
View profile  
 More options Oct 19 2012, 8:31 am
From: Karl Kristian Markman <karlkristian.mark...@gmail.com>
Date: Fri, 19 Oct 2012 05:31:57 -0700 (PDT)
Local: Fri, Oct 19 2012 8:31 am
Subject: Re: Converting LAt Long to UTM

To answer my own question. IT works, hallelujah.

For some reason (currently unknown to me) the java.lang.math needs to
have decimal point   in order to "understand" fractional powers.

Someone will probably tell me why in a sarcastic way. B)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RichardC  
View profile  
 More options Oct 19 2012, 9:01 am
From: RichardC <richard.crit...@googlemail.com>
Date: Fri, 19 Oct 2012 06:01:06 -0700 (PDT)
Local: Fri, Oct 19 2012 9:01 am
Subject: Re: Converting LAt Long to UTM

It's not  java.lang.math that needs to have the decimal point but Java the
language:
1/2 is integer 1 divided by integer 2 result integer 0
1.0/2.0 is double 1.0 divided by double 2.0 result double 0.5


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »