title: An exact method of area calculation using UTM coordinates
body: <p>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. </p>
  
  <p>I am first converting the coordinates to UTM using <a href="http://www.ibm.com/developerworks/java/library/j-coordconvert/" rel="nofollow">http://www.ibm.com/developerworks/java/library/j-coordconvert/</a></p>
  
  <p>From there, I am using <a href="http://www.mathopenref.com/coordpolygonarea2.html" rel="nofollow">http://www.mathopenref.com/coordpolygonarea2.html</a> to calculate the area of the UTM coordinates.</p>
  
  <pre><code>private Double polygonArea(int[] x, int[] y) {      
      Double area = 0.0;
      int j = x.length-1;
      for(int i = 0; i &lt; x.length; i++) {
          area = area + (x[j]+x[i]) * (y[j]-y[i]);
          j = i;
      }
      area = area/2;
      if (area &lt; 0)
          area = area * -1;
      return area;
  }
  </code></pre>
  
  <p>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? </p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>Thank you for the comments.
  Here is my code for getting the area (CoordinateConversion code is listed above on the IBM link):</p>
  
  <pre><code>private Map&lt;Integer, GeoPoint&gt; vertices;
  
  private Double getArea() {
      List&lt;Integer&gt; xpoints = new ArrayList&lt;Integer&gt;();
      List&lt;Integer&gt; ypoints = new ArrayList&lt;Integer&gt;();
      CoordinateConversion cc = new CoordinateConversion();
      for(Entry&lt;Integer, GeoPoint&gt; 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);
  }
  </code></pre>
  
  <p>Here is an example list of points:</p>
  
  <pre><code>44.80016800 -106.40808100
  44.80016800 -106.72123800
  44.75016800 -106.72123800
  44.75016800 -106.80123800
  44.56699100 -106.80123800
  </code></pre>
  
  <p>In ArcGIS and MS SQL server I get 90847.0 Acres.
  Using the code above I get 90817.4 Acres.</p>
  
  <p>Another example list of points:</p>
  
  <pre><code>45.78412600 -108.51506700
  45.78402600 -108.67972100
  45.75512200 -108.67949400
  45.75512200 -108.69962300
  45.69795400 -108.69929400
  </code></pre>
  
  <p>In ArcGIS and MS SQL server I get 15732.9 Acres.
  Using the code above I get 15731.9 Acres.</p>