i use jts.jar, package is com.vividsolutions.jts.geom, to get a geometry's area. but the method getArea() does not give me the right result. my code is
public static void main(String[] args) throws ParseException {
GeometryFactory geometryFactory = new GeometryFactory();
WKTReader reader = new WKTReader(geometryFactory);
String s = "MULTIPOLYGON (((114.273193 40.480272, 114.274645
MultiPolygon mpolygon = null;
mpolygon = (MultiPolygon) reader.read(s);
System.out.println(mpolygon.getArea());
}
After finding this question when looking for the an answer to similar question, i thought i'd share my findings:
Description taken from blog post as it explains the problem you are trying to solve:
Solution:
Output:
Reference: https://blog.ianturton.com/geotools,/projections/2017/08/01/area-of-a-polygon.html