4

I have a list of lat/long coordinates that I would like to use to calculate an area of a polygon. I can get exact in many cases, but the larger the polygon gets, the higher chance for error.

I am first converting the coordinates to UTM using http://www.ibm.com/developerworks/java/library/j-coordconvert/

From there, I am using http://www.mathopenref.com/coordpolygonarea2.html to calculate the area of the UTM coordinates.

private Double polygonArea(int[] x, int[] y) {      
    Double area = 0.0;
    int j = x.length-1;
    for(int i = 0; i < x.length; i++) {
        area = area + (x[j]+x[i]) * (y[j]-y[i]);
        j = i;
    }
    area = area/2;
    if (area < 0)
        area = area * -1;
    return area;
}

I compare these areas to the same coordinates I put into Microsoft SQL server and ArcGIS, but I cannot seem to match them exactly all the time. Does anyone know of a more exact method than this?

Thanks in advance.

EDIT 1

Thank you for the comments. Here is my code for getting the area (CoordinateConversion code is listed above on the IBM link):

private Map<Integer, GeoPoint> vertices;

private Double getArea() {
    List<Integer> xpoints = new ArrayList<Integer>();
    List<Integer> ypoints = new ArrayList<Integer>();
    CoordinateConversion cc = new CoordinateConversion();
    for(Entry<Integer, GeoPoint> itm : vertices.entrySet()) {
        GeoPoint pnt = itm.getValue();
        String temp = cc.latLon2MGRUTM(pnt.getLatitudeE6()/1E6, pnt.getLongitudeE6()/1E6);
        // Example return from CC: 02CNR0634657742
        String easting = temp.substring(5, 10);
        String northing = temp.substring(10, 15);
        xpoints.add(Integer.parseInt(easting));
        ypoints.add(Integer.parseInt(northing));
    }

    int[] x = toIntArray(xpoints);
    int[] y = toIntArray(ypoints); 
    return polygonArea(x,y);
}

Here is an example list of points:

44.80016800 -106.40808100
44.80016800 -106.72123800
44.75016800 -106.72123800
44.75016800 -106.80123800
44.56699100 -106.80123800

In ArcGIS and MS SQL server I get 90847.0 Acres. Using the code above I get 90817.4 Acres.

Another example list of points:

45.78412600 -108.51506700
45.78402600 -108.67972100
45.75512200 -108.67949400
45.75512200 -108.69962300
45.69795400 -108.69929400

In ArcGIS and MS SQL server I get 15732.9 Acres. Using the code above I get 15731.9 Acres.

Behr
  • 1,220
  • 18
  • 24
  • Does the area of your polygons change as the elevation of the world fluctuates? A place such as Kansas will have less "area" in a hectare than a place such as Switzerland. – sarnold Jun 05 '12 at 21:45
  • I would think that would affect it, but it is something I have not tried. The biggest elevation difference I have tried was between 300 meters and 1200 meters, and I have received exact on both, and not exact on both elevations. That does bring up a good point, since I have thousands of these polygons I will see if I can find a rhyme or reason to this. – Behr Jun 05 '12 at 22:16
  • Can you upload an example of the following form? 1. A set of coordinates (or a few). 2. All the code you execute to calculate an area. 3. The area you get when you execute the code 4. The area you get from SQL Server and ArcGIS. I don't have access to either of those but I'd still like to try and figure this out. – John Watts Jun 06 '12 at 00:01
  • @JohnWatts I edited the question to give an example of the issue and the proper measurements vs returned measurements. – Behr Jun 06 '12 at 15:12
  • @JimGarrison I think you may be correct, I'll see if I can dig anything up on that. I was guessing that having the points in UTM would give me good area measurements. – Behr Jun 06 '12 at 15:14

2 Answers2

0

The area formula you are using is valid only on a flat plane. As the polygon gets larger, the Earth's curvature starts to have an effect, making the area larger than what you calculate with this formula. You need to find a formula that works on a the surface of a sphere.

A simple Google search for "area of polygon on spherical surface" turns up a bunch of hits, of which the most interesting is Wolfram MathWorld Spherical Polygon

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
  • I am using the formula in your posted link and don't seem to be getting the desired results. I'll double check my code though. – Behr Jun 12 '12 at 16:37
0

It turns out that UTM just isn't able to get the extreme accuracy I was looking for. Switching projection systems to something more accurate like Albers or State Plane provided a much more accurate calculation.

Behr
  • 1,220
  • 18
  • 24