Area

Namespace: Digi21.DigiNG.Entities
Assembly: Digi21.DigiNG

Signed polygon area in the X, Y plane.

public double Area { get; }

Property value

Signed outer boundary area minus each hole's signed area. Each area is calculated as ReadOnlyLine.Area: positive for clockwise vertices and negative for counterclockwise vertices.

If holes have the same direction as the outer boundary, the result is the enclosed area's surface area (with the boundary's sign). If a hole has the opposite direction, its area is added rather than subtracted. To obtain surface area independently of vertex direction, subtract each hole's absolute area from the outer boundary's absolute area, as in the example.

The property does not check the vertex count: do not use it on a polygon without vertices.

Example

// Area + sum of hole areas = signed outer boundary area.
var áreaExterior = polígono.Area + polígono.Holes.Sum(h => h.Area);
var superficie = Math.Abs(áreaExterior) - polígono.Holes.Sum(h => Math.Abs(h.Area));