From: Roark D H. <rhe...@g7...> - 2010-07-08 18:19:20
|
First I hope this is the right place to post. I want to get the square miles (or metres) from a given polygon (I used a well known area feature as test data). I took the example: import org.geotools.geometry.jts.JTS; import org.geotools.referencing.CRS; CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:23032"); MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS); Geometry targetGeometry = JTS.transform( sourceGeometry, transform); and The sourceGeometry is a polygon representing a state boundary. I did a targetGeometry.getArea(); The result is way off ( I tested against CT) 5.2836281456E9 for CT. it should be around 5400 sq miles give or take a couple hundred. One site has it at 5544 sq miles. I also did Nebraska and got 6.70387746...E10, should have been approximately 77,300 sq miles. questions: What is the return value units? Should I be using a different CRS for north america as target? Is there a better way to do this? Any help appreciated |