ThinkGeo.com    |     Documentation    |     Premium Support

Convert UTM to DecimalDegree

Hi, I couldn't figure out which function to convert UTM format to DecimalDegree for longitude and latitude.


I know there's a class in 2.0 version, TransverseMercatorProj, can do the job.

I need to convert it because my map shape file only work with GeographyUnit set to Meter, and I need to display longitude and latitude in decimaldegree format. 



Any advice will be helpful.




Welcome to the community, Ching! 
  
 We are using PROJ4 in 3.0, which is quite different than the projection system we are using in 2.0. With Proj4, we don’t use one class for each projections anymore, instead we use an Srid number to represent one projection. For your case, you need to find the correct SRID number for the UTM you are using. Please check it within “C:\Program Files\ThinkGeo\Map Suite Desktop Evaluation Edition 3.0 (BETA)\Documentation\Projections\EPSG.rtf”. 
  
 Also for advanced usage, you can inherit the Projection class and create your own UTMToDecimalDegree projection, override the 2 methods ConvertToExternalProjectionCore and ConvertToInternalProjectionCore will be fine, just like how you create a new projection conversion class in 2.0. 
  
 Hope that helps. 
  
 Thanks, 
  
 Ben

Hi Ben, 
  
 I am really appreciate your help. You solved half of my problem. :) 
 I am actually pretty new to this api, I have spend past 3 days to play around with both 2.0 and 3.0 version. 
 Unforturnately I have to do a demo of 3.0 version next week to show what we can improve from 2.0 version. ( I was not the developer for 2.0 version, but I upgraded everything to 3.0 version and it’s working very well.) 
  
 If you can provide me steps to help me find the SRID, that will be very helpful. My ultimate goal is to display longtitude and latitude in DecimalDegree format. If I am asking the wrong question, please let me know. 
  
 Thanks in advance. 
  
 Ching

The SRID for UTM zone 19 N is 3179. I have an example on how to use Proj4Projection by displaying Longitude and Latitude on the map at the MouseMove event with layers in UTM. See the code in the MouseMove event: 
  
   private void winformsMap1_MouseMove(object sender, MouseEventArgs e) 
         { 
             PointShape WorldPointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, e.X, e.Y, winformsMap1.Width, 
 winformsMap1.Height); 
           Proj4Projection proj4Projection = new Proj4Projection(); 
                 proj4Projection.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(3179); //UTM 19N 
                 proj4Projection.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); //geodetic 
  
                 proj4Projection.Open(); 
                 Vertex geoVertex = proj4Projection.ConvertToExternalProjection(WorldPointShape.X, WorldPointShape.Y); 
                 proj4Projection.Close(); 
                 toolStripStatusLabel3.Text = @"Long: " + DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(geoVertex.X); 
                 toolStripStatusLabel4.Text = @"Lat: " + DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(geoVertex.Y); 
  
             }

Thank you Val and Ben, you guys are very helpful. 
 I got longitude and latitude displayed correctly on the screen now.

It’s our pleasure, Ching. :)