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

后端 未结 7 1956
孤街浪徒
孤街浪徒 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条回答
  •  野性不改
    2020-11-27 22:32

    I am modifying a Google Map so that a user can calculate the area of a polygon by clicking the vertices. It wasn't giving correct areas until I made sure the Math.cos(latAnchor) was in radians first

    So:

    double xPos = (lon-lonAnchor)*( Math.toRadians( 6378137 ) )*Math.cos( latAnchor );
    

    became:

    double xPos = (lon-lonAnchor)*( 6378137*PI/180 ) )*Math.cos( latAnchor*PI/180 );
    

    where lon, lonAnchor and latAnchor are in degrees. Works like a charm now.

提交回复
热议问题