1

计算面积:

var coordinates = new List<Coordinate> {
    new Coordinate(55, 35),
    new Coordinate(55, 35.1),
    new Coordinate(55.1, 35.1),
    new Coordinate(55.1, 35),
};
Console.WriteLine(new Polygon(coordinates).Area); // ~0.01

计算是正确的,因为它发生在正交坐标系中。

但是如何在 WGS 中标记坐标呢?

4

2 回答 2

2

看来这项任务比我预期的要复杂得多。我发现这个关于谷歌群组的有用讨论

首先我们需要找到最适合我们需要计算面积的区域的投影系统。例如,您可以选择UTM 区域之一

using DotSpatial.Projections;
using DotSpatial.Topology;
public static double CalculateArea(IEnumerable<double> latLonPoints)
{
    // source projection is WGS1984
    var projFrom = KnownCoordinateSystems.Geographic.World.WGS1984;
    // most complicated problem - you have to find most suitable projection
    var projTo = KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone37N;

    // prepare for ReprojectPoints (it's mutate array)
    var z = new double[latLonPoints.Count() / 2];
    var pointsArray = latLonPoints.ToArray();

    Reproject.ReprojectPoints(pointsArray, z, projFrom, projTo, 0, pointsArray.Length / 2);

    // assemblying new points array to create polygon
    var points = new List<Coordinate>(pointsArray.Length / 2);
    for (int i = 0; i < pointsArray.Length / 2; i++)
        points.Add(new Coordinate(pointsArray[i * 2], pointsArray[i * 2 + 1]));

    var poly = new Polygon(points);
    return poly.Area;
}
于 2017-09-12T14:19:40.767 回答
1

您可以直接从 IGeometry 或 Feature.Geometry 获取该区域。此外,您需要重复第一个坐标来关闭多边形。

FeatureSet fs = new FeatureSet(FeatureType.Polygon);

Coordinate[] coord = new Coordinate[]
{
    new Coordinate(55, 35),
    new Coordinate(55, 35.1),
    new Coordinate(55.1, 35.1),
    new Coordinate(55.1, 35),
    new Coordinate(55, 35)
};

fs.AddFeature(new Polygon(new LinearRing(coord)));

var area = fs.Features.First().Geometry.Area;
于 2018-07-24T02:03:56.540 回答