# How to convert UTM coordinate to Lat/Long coordinate

**URL:** <https://community.glideapps.com/t/how-to-convert-utm-coordinate-to-lat-long-coordinate/73125>\
**Category:** Ask for Help\
**Created:** [May 6, 2024, 7:38pm UTC](https://community.glideapps.com/t/how-to-convert-utm-coordinate-to-lat-long-coordinate/73125 "2024-05-06T19:38:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kemal1973](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kemal1973/32/72721_2.png) [@Kemal1973](https://community.glideapps.com/u/Kemal1973)\
**Post date:** [May 6, 2024, 7:38pm UTC](https://community.glideapps.com/t/how-to-convert-utm-coordinate-to-lat-long-coordinate/73125/1 "2024-05-06T19:38:29Z")

</div>

Hi everyone,  
In my Glide app I want to users enter UTM coordinate and app convert this to latitude and longitude coordinate.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 6, 2024, 8:58pm UTC](https://community.glideapps.com/t/how-to-convert-utm-coordinate-to-lat-long-coordinate/73125/2 "2024-05-06T20:58:18Z")

</div>

Can you verify the format of how you would receive the utm coordinates, so I can make sure I’m giving you the correct javascript?

---

<div class="post-metadata">

**Author:** ![Kemal1973](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kemal1973/32/72721_2.png) [@Kemal1973](https://community.glideapps.com/u/Kemal1973)\
**Post date:** [May 6, 2024, 9:30pm UTC](https://community.glideapps.com/t/how-to-convert-utm-coordinate-to-lat-long-coordinate/73125/3 "2024-05-06T21:30:13Z")

</div>

User enter a 15 digits number for example 619298421586038  
app will separate 6 digits,7 digits and 2 digits from left hand  
619298  
4215860  
38  
there are some website like [https://www.geoplaner.com](https://www.geoplaner.com) that do this  
but I can’t connect Glide to those website

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 6, 2024, 10:07pm UTC](https://community.glideapps.com/t/how-to-convert-utm-coordinate-to-lat-long-coordinate/73125/4 "2024-05-06T22:07:11Z")

</div>

Try this in a javascript column and point the p1 parameter at the column that contains the user input.

```auto
function Utm2LatLng( X,Y,zone,sn) {
    if (sn=='S')
    {
        Y = Y - 10000000;
    }
    X = X - 500000;
    var sa = 6378137.000000;
    var sb = 6356752.314245;

   var e = Math.pow( Math.pow(sa , 2) - Math.pow(sb , 2) , 0.5 ) / sa;
   var e2 = Math.pow( Math.pow( sa , 2 ) - Math.pow( sb , 2 ) , 0.5 ) / sb;
   var e2cuadrada = Math.pow(e2 , 2);
   var c = Math.pow(sa , 2 ) / sb;

   var S = ( ( zone * 6 ) - 183 ); 
   var lat = Y / ( 6366197.724 * 0.9996 );                         
   var v = (c * 0.9996)/ Math.pow( 1 + ( e2cuadrada * Math.pow( Math.cos(lat), 2 )) , 0.5 ) ;
   var a = X / v;
   var a1 = Math.sin( 2 * lat );
   var a2 = a1 * Math.pow( Math.cos(lat), 2);
   var j2 = lat + ( a1 / 2 );
   var j4 = ( ( 3 * j2 ) + a2 ) / 4;
   var j6 = ( ( 5 * j4 ) + ( a2 * Math.pow( Math.cos(lat) , 2) ) ) / 3;
   var alfa = ( 3 / 4 ) * e2cuadrada;
   var beta = ( 5 / 3 ) * Math.pow(alfa , 2);
   var gama = ( 35 / 27 ) * Math.pow(alfa , 3);
   var Bm = 0.9996 * c * ( lat - alfa * j2 + beta * j4 - gama * j6 );
   var b = ( Y - Bm ) / v;
   var Epsi = ( ( e2cuadrada * Math.pow(a , 2)) / 2 ) * Math.pow( Math.cos(lat) , 2);
   var Eps = a * ( 1 - ( Epsi / 3 ) );
   var nab = ( b * ( 1 - Epsi ) ) + lat;
   var senoheps = ( Math.exp(Eps) - Math.exp(-Eps) ) / 2;
   var Delt = Math.atan(senoheps / Math.cos(nab) );
   var TaO = Math.atan(Math.cos(Delt) * Math.tan(nab));
   var longitude = (Delt *(180 / Math.PI ) ) + S;
   var latitude = ( lat + ( 1 + e2cuadrada* Math.pow(Math.cos(lat), 2) - ( 3 / 2 ) * e2cuadrada * Math.sin(lat) * Math.cos(lat) * ( TaO - lat ) ) * ( TaO - lat ) ) * (180 / Math.PI);
    return latitude.toString().concat(", " + longitude.toString()) ;
}

const number = p1;
const zone = parseInt(number.toString().substring(13)); // Extract the last 2 digits as zone
const easting = parseInt(number.toString().substring(0, 6)); // Extract the first 6 digits as easting
const northing = parseInt(number.toString().substring(6, 13)); // Extract the next 7 digits as northing
const northernHemisphere = 'N'; // You should have a way to determine this based on your input

return Utm2LatLng(easting, northing, zone, northernHemisphere);

```

---

<div class="post-metadata">

**Author:** ![Kemal1973](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kemal1973/32/72721_2.png) [@Kemal1973](https://community.glideapps.com/u/Kemal1973)\
**Post date:** [May 6, 2024, 10:32pm UTC](https://community.glideapps.com/t/how-to-convert-utm-coordinate-to-lat-long-coordinate/73125/5 "2024-05-06T22:32:47Z")

</div>

> [@Kemal1973](#):
>
> 4215860

Thank you so much

 ![utm](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/1/613cfed391aa43c9aabb56638111308d1e0d8fa8.png)  
I run but there is a problem

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 7, 2024, 1:04am UTC](https://community.glideapps.com/t/how-to-convert-utm-coordinate-to-lat-long-coordinate/73125/6 "2024-05-07T01:04:21Z")

</div>

I think the error is just related to your empty inputs (for below rows). It shouldn’t affect what you’re trying to do.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [May 7, 2024, 1:10am UTC](https://community.glideapps.com/t/how-to-convert-utm-coordinate-to-lat-long-coordinate/73125/7 "2024-05-07T01:10:06Z")

</div>

Yeah, like @ThinhDinh mentioned, the error doesn’t affect anything. Its just a warning, but it if bothers you, here is a modified version that just returns nothing if p1 is empty.

```auto
function Utm2LatLng( X,Y,zone,sn) {
    if (sn=='S')
    {
        Y = Y - 10000000;
    }
    X = X - 500000;
    var sa = 6378137.000000;
    var sb = 6356752.314245;

   var e = Math.pow( Math.pow(sa , 2) - Math.pow(sb , 2) , 0.5 ) / sa;
   var e2 = Math.pow( Math.pow( sa , 2 ) - Math.pow( sb , 2 ) , 0.5 ) / sb;
   var e2cuadrada = Math.pow(e2 , 2);
   var c = Math.pow(sa , 2 ) / sb;

   var S = ( ( zone * 6 ) - 183 ); 
   var lat = Y / ( 6366197.724 * 0.9996 );                         
   var v = (c * 0.9996)/ Math.pow( 1 + ( e2cuadrada * Math.pow( Math.cos(lat), 2 )) , 0.5 ) ;
   var a = X / v;
   var a1 = Math.sin( 2 * lat );
   var a2 = a1 * Math.pow( Math.cos(lat), 2);
   var j2 = lat + ( a1 / 2 );
   var j4 = ( ( 3 * j2 ) + a2 ) / 4;
   var j6 = ( ( 5 * j4 ) + ( a2 * Math.pow( Math.cos(lat) , 2) ) ) / 3;
   var alfa = ( 3 / 4 ) * e2cuadrada;
   var beta = ( 5 / 3 ) * Math.pow(alfa , 2);
   var gama = ( 35 / 27 ) * Math.pow(alfa , 3);
   var Bm = 0.9996 * c * ( lat - alfa * j2 + beta * j4 - gama * j6 );
   var b = ( Y - Bm ) / v;
   var Epsi = ( ( e2cuadrada * Math.pow(a , 2)) / 2 ) * Math.pow( Math.cos(lat) , 2);
   var Eps = a * ( 1 - ( Epsi / 3 ) );
   var nab = ( b * ( 1 - Epsi ) ) + lat;
   var senoheps = ( Math.exp(Eps) - Math.exp(-Eps) ) / 2;
   var Delt = Math.atan(senoheps / Math.cos(nab) );
   var TaO = Math.atan(Math.cos(Delt) * Math.tan(nab));
   var longitude = (Delt *(180 / Math.PI ) ) + S;
   var latitude = ( lat + ( 1 + e2cuadrada* Math.pow(Math.cos(lat), 2) - ( 3 / 2 ) * e2cuadrada * Math.sin(lat) * Math.cos(lat) * ( TaO - lat ) ) * ( TaO - lat ) ) * (180 / Math.PI);
    return latitude.toString().concat(", " + longitude.toString()) ;
}

if (!p1) {
  return '';
}
const number = p1;
const zone = parseInt(number.toString().substring(13)); // Extract the last 2 digits as zone
const easting = parseInt(number.toString().substring(0, 6)); // Extract the first 6 digits as easting
const northing = parseInt(number.toString().substring(6, 13)); // Extract the next 7 digits as northing
const northernHemisphere = 'N'; // You should have a way to determine this based on your input

return Utm2LatLng(easting, northing, zone, northernHemisphere);

```

---

<div class="post-metadata">

**Author:** ![Kemal1973](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/kemal1973/32/72721_2.png) [@Kemal1973](https://community.glideapps.com/u/Kemal1973)\
**Post date:** [May 7, 2024, 1:09pm UTC](https://community.glideapps.com/t/how-to-convert-utm-coordinate-to-lat-long-coordinate/73125/8 "2024-05-07T13:09:01Z")

</div>

> [@Kemal1973](#):
>
> 619298421586038

Thank you very much  
It ran correctly 👋 👋
