Just a follow up. The source projection was wrong. Changed the source to DefaultGeographicCRS.WGS84. I also have a map of states to NAD83 Harn EPSG:NNNNs for the target.
Now the areas are within a percentage point or two of the various web sites. Thanks for the help. On Jul 12, 2010, at 10:45 AM, Roark D Hennessy wrote: > I've tried multiply target projections, none come close. > > So I'm wondering if my source is set incorrectly. > > The source data is a WGS84 geographic projection (I'm not sure why they call > it a projection since its in decimal degrees lat/lons ie. -75.127811, > 38.669757 ). > > My current question is whether I am setting the source correctly as EPSG:4326 > or should it be a different value? Is there some way that I can interrogate > the data to know what I should be setting the value to? > > I'm using the hsqldb import as the backing store for projections. > > Thanks again. > > PS. > > My latest run was using EPSG:26756 and the targetGeometry.getArea() returned > 7.095211288232647E12 > > > On Jul 8, 2010, at 6:01 PM, Ian Turton wrote: > >> On Thu, Jul 8, 2010 at 2:19 PM, Roark D Hennessy >> <[email protected]> wrote: >>> 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? >> >> The returned value is the units of your projection squared. So >> according to units >> You have: m^2 >> You want: miles^2 >> * 3.8610216e-07 >> / 2589988.1 >> >> You need to calculate >> 5.2836281456E9 * 3.8610216e-07 = 2040.02024 >> >> which looks off (but much closer) to your answer of 5400 (though the >> census bureau says 4844 >> http://quickfacts.census.gov/qfd/states/09000.html) >> >> >>> Should I be using a different CRS for north america as target? >> >> EPSG:2163 is probably better. >> >> Ian >> -- >> Ian Turton >> > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Geotools-gt2-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
