Converting Lat/Long to MapPoint

2486
2
08-18-2016 08:59 AM
HuyHo
by
Occasional Contributor

When I try to convert a Lat/Long coordinate to a MapPoint (in NAD_1927_UTM_Zone_17N), I am getting two different results.  If I use GeometryEngine.Project() from a mapPoint in Wgs84 using lat/long values, I get the location in red.  When I use ConvertCoordinate.FromDecimalDegrees(), I get the blue point.  Why is there this difference?  I tried using ArcMap to locate lat/long, it gives the same location as the ConvertCoordinate class.  Funny thing is when I tried it with Google, it matches the red point.  So which is correct?

double latitude = double.Parse(LatText.Text);
 double longitude = double.Parse(LongText.Text);
SpatialReference spref = new SpatialReference(2617); // NAD_1927_UTM_Zone_17N
MapPoint baseMapPoint = new MapPoint(longitude, latitude, SpatialReferences.Wgs84);
 MapPoint mapPoint1 = GeometryEngine.Project(baseMapPoint, spref) as MapPoint;
 _graphic1.Geometry = mapPoint1;
MapPoint mapPoint2 = ConvertCoordinate.FromDecimalDegrees(string.Format("{0},{1}", latitude, longitude), spref);
 _graphic2.Geometry = mapPoint2;
2 Replies
ThadTilton
Esri Contributor

Interesting ...

I'll explore it a little further, but on the surface (no pun intended), the only thing that stands out is the fact that GeometryEngine.Project uses a map point with an explicitly defined datum (from WGS 84), while ConvertCoordinate.FromDecimalDegrees does not. I would assume that WGS 84 is used for the conversion, but maybe not (?). Maybe a different datum (surface) is being used for that conversion and that accounts for the difference.

BTW - the WKID for NAD 1927 UTM 17N is 26717 (you're missing the middle "7").

0 Kudos
ThadTilton
Esri Contributor

I geeked out with this for a while. Although I still don't have an answer for you, I've found a pattern that points to different "datums" (models of the Earth's surface) being used in the conversions.


If I check the converted and projected values for different input coordinates, they match for latitudes between 19.75 and 50.25 N (longitude doesn't seem to be a factor).


Here's the code I tested with:

double latitude = double.Parse("50.250000"); // No difference if values are between 19.75N and 50.25N
double longitude = double.Parse("-81.000000"); // 81.0W is the central meridian for UTM 17N
SpatialReference spref = new SpatialReference(26717); // NAD_1927_UTM_Zone_17N
MapPoint baseMapPoint = new MapPoint(longitude, latitude, SpatialReferences.Wgs84);

MapPoint mapPoint1 = GeometryEngine.Project(baseMapPoint, spref) as MapPoint;
MapPoint mapPoint2 = ConvertCoordinate.FromDecimalDegrees(string.Format("{0},{1}", latitude, longitude), spref);

var xDiff = Math.Abs(mapPoint2.X - mapPoint1.X);
var yDiff = Math.Abs(mapPoint2.Y - mapPoint1.Y);

// Check the difference in latitude (Y) and longitude (X)
// It is 0 when initial latitude is south of 19.75N or north of 50.25N
Debug.Print("Difference X: " + xDiff);
Debug.Print("Difference Y: " + yDiff);
0 Kudos