Jody Garnett wrote:
> 
> The shapefile code will read the prj file for you; the value is 
> available as:
> 
> CoordianteReferenceSystem sourceCRS = 
> shapefiledatastore.getSchema().getDefaultGeometry().getCoordianteReferenceSystem().
> 
> I am a bit worried that cannot understand your problem; reading you 
> email it sounds like the above value would be a "state plane" format? 
> And you may
> be asking how to reproject the data to "EPSG:4326". If you simply want 
> find the best match for sourceCRS and ask the data store to use it ...
> 
> CoordianteReferenceSystem exactCRS = CRS.lookupIdentifier( sourceCRS, 
> true );
> shapefiledatastore.forceCRS( exactCRS ); // this exact CRS from the epsg 
> database will be used by the shapefile from here on out
> 
> Cheers,
> Jody
> 

Thanks for the reply, Jody.   As I said, I'm very new, so apologies if I'm
not asking my question very clearly.  Basically, what I'm trying to do is
extract the lat/long coordinates of the geometries in a shapefile, but those
geometries are currently represented in a state plane CRS.  So my major goal
is to find the MathTransform that goes from input format to EPSG:4326, so
that I can apply this to the geometries in my file and essentially dump out
the resulting lat/long coordinates.

I've tried the code you suggest above.  The getCoordina
teReferenceSystem returns a CRS which, when converted to a String, looks
like my .prj file:

PROJCS["NAD_1983_StatePlane_Massachusetts_Mainland_FIPS_2001",
  GEOGCS["GCS_North_American_1983",
    DATUM["D_North_American_1983",
      SPHEROID["GRS_1980", 6378137.0, 298.257222101]],
    PRIMEM["Greenwich", 0.0],
    UNIT["degree", 0.017453292519943295],
    AXIS["Longitude", EAST],
    AXIS["Latitude", NORTH]],
  PROJECTION["Lambert_Conformal_Conic"],
  PARAMETER["central_meridian", -71.5],
  PARAMETER["latitude_of_origin", 41.0],
  PARAMETER["standard_parallel_1", 41.71666666666667],
  PARAMETER["scale_factor", 1.0],
  PARAMETER["false_easting", 200000.0],
  PARAMETER["false_northing", 750000.0],
  PARAMETER["standard_parallel_2", 42.68333333333334],
  UNIT["m", 1.0],
  AXIS["x", EAST],
  AXIS["y", NORTH]]

Notice that there are useful (to a human) names here, but no Bursa Wolf
parameters that would allow this to be easily digested by a machine.

Now when I try your other suggestion: CRS.lookupIdentifier( sourceCRS, true
); I get an exception:

org.opengis.referencing.FactoryException: Geotools extension required for
"getIdentifiedObjectFinder" operation.
        at
org.geotools.referencing.factory.AuthorityFactoryAdapter.getGeotoolsFactory(AuthorityFactoryAdapter.java:503)
        at 
...

It seems I need some tool which will take the name
NAD_1983_StatePlane_Massachusetts_Mainland_FIPS_2001 and make a best guess
as to what EPSG code I need, much as I would do by looking at the EPSG
online database.  Can GeoTools do this?
-- 
View this message in context: 
http://www.nabble.com/Automatically-parsing-.prj-files--tp15026215p15029463.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to