Polygon area calculation using Latitude and Longitude generated from Cartesian space and a world file

后端 未结 7 1961
孤街浪徒
孤街浪徒 2020-11-27 22:16

Given a series of GPS coordinate pairs, I need to calculate the area of a polygon (n-gon). This is relatively small (not larger than 50,000 sqft). The geocodes are created

7条回答
  •  萌比男神i
    2020-11-27 22:24

    Thank you Risky Pathak!

    In the spirit of sharing, here's my adaptation in Delphi:

    interface
    
    uses 
      System.Math; 
    
    TMapGeoPoint = record
      Latitude: Double;
      Longitude: Double;
    end;
    
    
    function AreaInAcres(AGeoPoints: TList): Double;
    
    implementation
    
    function AreaInAcres(AGeoPoints: TList): Double;
    var
      Area: Double;
      i: Integer;
      P1, P2: TMapGeoPoint;
    begin
     Area := 0;
    
     // We need at least 2 points
     if (AGeoPoints.Count > 2) then
     begin
       for I := 0 to AGeoPoints.Count - 1 do
       begin
         P1 := AGeoPoints[i];
         if i < AGeoPoints.Count - 1  then
           P2 := AGeoPoints[i + 1]
         else
           P2 := AGeoPoints[0];
         Area := Area + DegToRad(P2.Longitude - P1.Longitude) * (2 + 
            Sin(DegToRad(P1.Latitude)) + Sin(DegToRad(P2.Latitude)));
        end;
    
        Area := Area * 6378137 * 6378137 / 2;
    
      end;
    
      Area := Abs(Area); //Area (in sq meters)
    
      // 1 Square Meter = 0.000247105 Acres
      result := Area * 0.000247105;
    end;
    

提交回复
热议问题