我将UTM坐标(X / Y)(基准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];
}
答案 0 :(得分:0)
我认为关键是Datum ED50
你是对的。您将UTM坐标与基准WGS84转换为LatLong坐标,基准WGS84。由于UTM坐标使用基准ED50,因此必须为原始坐标指定它而不是WGS84。
我不熟悉DotSpatial,但一个疯狂的猜测就是你需要做这样的事情:
string utmStr = "+proj=utm +zone=30 +ellps=Hayford +datum=ED50 +units=m +no_defs ";
(前提是 Hayford 是适当的椭球和 ED50 在DotSpatial中用于此类数据。)
答案 1 :(得分:0)
对于那些想知道如何使用DotSpatial通过形状文件重新投影到不同坐标系的人来说,这就是我的方法。
通过nuget,您将需要这些依赖项。
DotSpatial.NetTopologySuite(v1.14.4)
// open the shape file into a feature set
var fs = FeatureSet.Open("someshapefile.shp");
// fill the attributes table including related data from the dbf file
// this is not required but if you plan to access the data within the .dbf then you'll need to
fs.FillAttributes();
// check if the projection is not lat/lng
// this assumes that the shapefile has a .prj file with projection info that it can parse
if (!fs.Projection.IsLatLon)
{
// reproject to the coordinate system of your choice
fs.Reproject(KnownCoordinateSystems.Geographic.World.WGS1984);
}
我认为这适用于任何投影到任何投影,但我尚未测试其他投影。