0

I have to convert a coordinate from UTM to MGRS. I think I have the most of it covered, but I have some difficulties to calculate the correct Latitude-band. How can I decide which band the coordinate has?

1 Answer 1

2

I use:

zone = math.floor ((lon + 180.0) / 6) + 1

Bear with me on that, and I'll check my library

So if

lon = -35
lat = 35

Then zone will be 25, which I think is correct. Try it and let me know if it works for you.

There is also:

andrewlesley.freeserve.co.uk/gps/convertr/UTM-MGRS.html

I am sure you can get into the JS and use the code.

var UTMzdlChars="CDEFGHJKLMNPQRSTUVWXX"; 
function UTMzdl(latDeg) 
{ 
    if(-80<=latDeg&&latDeg<=84) 
    {
        return UTMzdlChars.charAt(Math.floor((latDeg+80)/8));

    }else 
    { 
         //Not normally reached 
         alert("No zdl: UTM is not valid for Lat "+latDeg); 
         return ""; 
     } 
} 
6
  • 1
    Thank you, but I already have the zone. What I need is the Latitude-band, thats a letter. It is normally told together with the zone, i.e. 32V. I need to determine the V-part.
    – Mnementh
    Commented Oct 12, 2011 at 10:36
  • 1
    I found this: andrewlesley.freeserve.co.uk/gps/convertr/UTM-MGRS.html and I am sure you can crack into their js and get the functions out.
    – Hairy
    Commented Oct 12, 2011 at 10:54
  • I "cracked" into their js (or looked the source of the site) and found: var UTMzdlChars="CDEFGHJKLMNPQRSTUVWXX"; function UTMzdl(latDeg) { if(-80<=latDeg&&latDeg<=84) return UTMzdlChars.charAt(Math.floor((latDeg+80)/8)); else { alert("No zdl: UTM is not valid for Lat "+latDeg); //Not normally reached return ""; } } Thank you!
    – Mnementh
    Commented Oct 12, 2011 at 11:10
  • No worries, glad to have helped, I'llput it in my answer so you cna upvote me and get me past 2000 ;)
    – Hairy
    Commented Oct 12, 2011 at 11:27
  • 2
    Ok, I will upvote, if the answer contains that.
    – Mnementh
    Commented Oct 12, 2011 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.