1

我将 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];
}
4

2 回答 2

0

我认为关键是 Datum ED50

你是对的。您正在将具有基准 WGS84 的 UTM 坐标转换为具有基准 WGS84 的 LatLong 坐标。由于您的 UTM 坐标使用基准 ED50,因此您必须为原始坐标指定它而不是 WGS84。

我不熟悉 DotSpatial 但一个疯狂的猜测是你需要做这样的事情:

string utmStr = "+proj=utm +zone=30 +ellps=Hayford +datum=ED50 +units=m +no_defs ";

(假设Hayford是合适的椭球体,并且ED50在 DotSpatial 中用于此类基准面。)

于 2015-12-17T16:07:02.543 回答
0

对于那些想知道如何通过形状文件使用 DotSpatial 重新投影到不同坐标系的人,我就是这样做的。

尽管通过 nuget,您将需要这些依赖项。

  • DotSpatial.Data (v2.0.0-rc1)
  • DotSpatial.GeoAPI (v1.7.4.3)
  • 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);
    }
    

我认为这适用于任何投影到任何投影,但我没有测试过其他投影。

于 2018-06-21T21:37:06.353 回答