我将 UTM 坐标 (X/Y) (Datum ED50) 转换为纬度/经度,但结果不准确。至少有 500 米的误差。
我使用了库https://proj4net.codeplex.com/
我认为关键是 Datum ED50
这是我的代码:
//Zone: 30N
public static string ConvertTolatlngString(double utmX, double utmY)
{
//Transform to latlong
CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
ICoordinateSystem wgs84geo = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
ICoordinateSystem utm = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(30, true);
ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(utm,wgs84geo);
double[] pUtm = trans.MathTransform.Transform(new double[] { utmX, utmY });
double latfromutm = pUtm[1];
double longfromutm = pUtm[0];
return String.Format("{0},{1}", latfromutm,longfromutm);
}
更新
我也使用过 DotSpatial ( https://dotspatial.codeplex.com ) 但我得到了相同的结果:
public static void UTMToLatLongDSP(double X, double Y, out double latitude, out double longitude)
{
double[] XY = new double[2];
XY[0] = X;
XY[1] = Y;
double[] Z = new double[1];
Z[0] = 1;
string utmStr = "+proj=utm +zone=30 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ";
}
ProjectionInfo projIn = ProjectionInfo.FromProj4String(utmStr);
ProjectionInfo projOut = KnownCoordinateSystems.Geographic.World.WGS1984;
Reproject.ReprojectPoints(XY, Z, projIn, projOut, 0, 1);
longitude = XY[0];
latitude = XY[1];
}
更新 2 我指定了 EPGS 代码,但没有得到预期的结果。这是我的新代码:
public static void UTMToLatLongDSP(double X, double Y, out double latitude, out double longitude)
{
double[] xy = new double[] { X, Y };
double[] z = new double[] { 0 };
// Source projection information.
ProjectionInfo source = KnownCoordinateSystems.Projected.UtmOther.EuropeanDatum1950UTMZone30N;
source.GeographicInfo.Datum.Spheroid.KnownEllipsoid = Proj4Ellipsoid.International_1909;
source.AuthorityCode = 23030;
// Destination projection information
ProjectionInfo dest = KnownCoordinateSystems.Geographic.World.WGS1984;
dest.AuthorityCode = 4326;
// Call the projection utility.
Reproject.ReprojectPoints(xy, z, source, dest, 0, 1);
longitude = xy[0];
latitude = xy[1];
}