Code covered by the BSD License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

### Highlights from deg2utm

4.90909
4.9 | 11 ratings Rate this file 150 Downloads (last 30 days) File Size: 2.61 KB File ID: #10915 Version: 1.0

# deg2utm

### Rafael Palacios (view profile)

29 Apr 2006 (Updated )

Function to convert lat/lon vectors into UTM coordinates (WGS84)

File Information
Description

This function is based on UTM.m function by Gabriel Ruiz Martinez, but instead of providing a GUI it works with vectors of coordinates.
[x,y,utmzone] = deg2utm(Lat,Lon)
% Example 1:
% Lat=[40.3154333; 46.283900; 37.577833; 28.645650; 38.855550; 25.061783];
% Lon=[-3.4857166; 7.8012333; -119.95525; -17.759533; -94.7990166; 121.640266];
% [x,y,utmzone] = deg2utm(Lat,Lon);
% fprintf('%7.0f ',x)
% 458731 407653 239027 230253 343898 362850
% fprintf('%7.0f ',y)
% 4462881 5126290 4163083 3171843 4302285 2772478
% utmzone =
% 30 T
% 32 T
% 11 S
% 28 R
% 15 S
% 51 R
%
% Example 2: If you have Lat/Lon coordinates in Degrees, Minutes and Seconds
% LatDMS=[40 18 55.56; 46 17 2.04];
% LonDMS=[-3 29 8.58; 7 48 4.44];
% Lat=dms2deg(mat2dms(LatDMS)); %convert into degrees
% Lon=dms2deg(mat2dms(LonDMS)); %convert into degrees
% [x,y,utmzone] = deg2utm(Lat,Lon)
%

Acknowledgements

Conversion Of Spherical Coordinates To Utm Coordinates inspired this file.

This file inspired Sp Proj, Wgs2utm (Version 2), Utm2lonlat, and Get Google Map.

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File   Please login to tag files.
 Please login to add a comment or rating.
Comments and Ratings (22)
02 Jun 2016 tuan

### tuan (view profile)

It works fine for an area with single utmzone. But for area with location has more than one utmzone it produces X (East direction) not correctly.

Could anyone help me to figure out?

Thanks

Comment only
12 Mar 2015 Mohammad Hannan Khan

### Mohammad Hannan Khan (view profile)

It was okay.. My mistake! Thanks

Comment only
09 Oct 2014 Federico

### Federico (view profile)

The function works perfectly, but I have doubts on the outputs: which one represents easting (i.e. longitudinal information) and which one the northing (latitudinal information)?

Comment only
08 Jul 2014 Kyle

### Kyle (view profile)

Oops, I got it to work - - just my newness to the software.

Forgot to specify the outputs I wanted.

For people like me (getting into matlab), make sure to put your outputs you want in the command window.
IE: [x,y,utmzone] = deg2utm(Lat,Lon), where if you want x, y, and the utmzone you have to tell matlab that. Else it will only give you x (which is what I was getting before hand).
EDU>> [x,y,utmzone] = deg2utm(38.130587, -99.081752)
x = 4.9284e+05
y = 4.2203e+06
utmzone = 14 S

Comment only
07 Jul 2014 Aleksander

### Aleksander (view profile)

Hi.
i am unsure if this is a issue or not.
if i input the following:
[x,y]=deg2utm([5153.7870,5153.7870],[00425.8690,00425.8685])
i expect that the x output is the samme for both cordinates, and that i have a diferense of only 0.58m in the y, how ever the diference in x is about 1M and in y about 22,5M. any thoughts ?

Comment only
18 Feb 2014 jack

### jack (view profile)

thank you very much.

Comment only
13 Feb 2014 r nawaz

### r nawaz (view profile)

Henry:

I have converted column 1 and 2, the deg2utm works perfectly fine. The lat/longs are from UTM zone 16 to zone 14 (from top to bottom). Note that easting suddenly increases as you move from a higher UTM zone number to lower one. There is not much change in Lats so that zone northing remains from letter Q. Column 3 and 4 has wrong transformed values.

Comment only
06 Feb 2014 Saúl

### Saúl (view profile)

03 Feb 2014 Henry

### Henry (view profile)

I have problems converting the 1st and 2nd columns. The 3rd and 4th columns are the correct transformed values.. Any help?

18.9000000000000 -85.6000000000000 1016636.08476000 2097349.08510000
19.1000000000000 -86.2000000000000 952730.286652000 2117881.16418000
19.3000000000000 -86.7000000000000 899537.751857000 2138832.87892000
19.5000000000000 -87.2000000000000 846493.267934000 2159917.67197000
19.6000000000000 -87.5000000000000 814775.913438000 2170418.08636000
19.8000000000000 -87.9000000000000 772442.462010000 2191882.52618000
20.3000000000000 -88.8000000000000 677544.995001000 2246042.98172000
20.5000000000000 -89.8000000000000 573005.667765000 2267422.61128000
20.5000000000000 -91.0000000000000 447853.577293000 2267346.10988000
20.3000000000000 -91.7000000000000 374681.174733000 2245584.33154000
20.1000000000000 -92.2000000000000 322228.063533000 2223898.57802000
19.8000000000000 -93.2000000000000 217073.073883000 2192046.90591000
19.2000000000000 -94.1000000000000 121283.019710000 2127298.41915000
18.6000000000000 -94.9000000000000 35345.9851048000 2062679.39657000
17.9000000000000 -95.6000000000000 -40894.3144760000 1986930.91879000
17.2000000000000 -96.4000000000000 -128393.538814000 1911652.44510000
16.9000000000000 -97.0000000000000 -193630.694790000 1880339.46191000

thanks!

Comment only
11 Jul 2013 asad mavalizadeh

### asad mavalizadeh (view profile)

arg, sorry my fault, its no bug

Comment only
11 Jun 2013 Gerald Lodron Lodron

### Gerald Lodron Lodron (view profile)

arg, sorry my fault, its no bug

11 Jun 2013 Gerald Lodron Lodron

### Gerald Lodron Lodron (view profile)

I found a bug, in this example the first point P95 is mapped correctly to google maps, but EP2 differs about 70 Meters from GPS coordinates in carthesian:

P95 = [15.425789 47.030778];
[P95_Carthesian(1) P95_Carthesian(2)] = deg2utm(P95(2), P95(1));

EP2 = [15.42604688057756 47.03090763127457];

[EP2_Carthesian(1) EP2_Carthesian(2)] = deg2utm(EP2(2), EP2(1));

Comment only
26 Jan 2011 S. A. van der Wulp

### S. A. van der Wulp (view profile)

10 Jan 2011 r nawaz

16 Nov 2010 Anna

### Anna (view profile)

Hello!
I have a question about this script:
I want to convert lat lon points in the Northern Shelf Sea (Europe) to coordinates which have the unit meters. So I thought using UTM coordinates was the best solution.
However, the area is quite big (1000km x 1000km) and contains different zones. So after converting, my points are not in the right order any more. So either it is simply not possible to have points of different zones in one data base or the script makes some mistake.
Can somebody help me with this issue?
Thank you. Anna

Comment only
02 Sep 2008 E Bobane

I have my Lat/Lon coordinates in Degrees, Minutes and Seconds (as in your Example 2). However I am missing the 'dms2deg' and 'mat2dms' functions. Are these in some toolbox or part of this submission.

03 Jan 2008 Tony Gibb
22 Jun 2007 Andy Gardos

Excellent Script! I wonder if you would provide some comments for the calculation section. I've compared some lat/lon data to actual x,y profiles; however, I've found that I must multiply the x and y valuse derived from deg2utm by approximately 3.2 to match the actual values?! Thanks! Again, great script!!!

26 Jan 2007 Junseok Park

Excellent!! And Thank you. This is applied for Korea.

25 Oct 2006 Anthony Liou

Great stuff~ Thank you very much.

11 Jul 2006 Philippe Blondel

Very good ! Thank you very much !

06 Jun 2006 oh kwoun

Thanks a lot!

Updates
29 Jun 2006

Update description. Minor fixes

03 Aug 2006

Fixed a problem with southern hemisphere coordinates. Now it works properly.

Contact us