Dear all, I would like to use geotools library for transform among different coordinate systems and datums. I have read the user-guide, however I still can't figure out how to use the code to do any transform yet. I appreciate all helps and guides. Thank you very much in advance.
Here is my first test: Converting from GCS (lat,long,height) to XYZ coordinates (geocentric or ECEF) public GCS2ECEF(String latitude, String longitude, String height) { lat = Double.parseDouble(latitude); lon = Double.parseDouble(longitude); this.height = Double.parseDouble(height); try { defaultcrs = CRS.decode("EPSG:4957"); //as HARN geographic 3D targetcrs = CRS.decode("EPSG:4956"); //as HARN geocentric MathTransform transform = CRS.findMathTransform(defaultcrs, targetcrs); source = new DirectPosition3D(defaultcrs,lat,lon,this.height); result = new DirectPosition3D(targetcrs,lat,lon,this.height); transform.transform(source, result); System.out.println("x = " + result.getOrdinate(0)); System.out.println("y = " + result.getOrdinate(1)); System.out.println("z = " + result.getOrdinate(2)); } catch (NoSuchAuthorityCodeException e) { e.printStackTrace(); }catch (FactoryException e){ e.printStackTrace(); }catch(TransformException e){ e.printStackTrace(); } } Error message as below: Jan 12, 2010 4:22:53 PM org.geotools.factory.FactoryRegistry scanForPlugins WARNING: Can't load a service for category "MathTransformProvider". Cause is "NoClassDefFoundError: javax/media/jai/WarpAffine". org.opengis.referencing.operation.OperationNotFoundException: No transformation available from system "CartesianCS[Geocentric]" to "CartesianCS[Earth centred, earth fixed, righthanded 3D coordinate system, consisting of 3 (...) positive Z-axis parallel to mean earth rotation axis and pointing towards North Pole. UoM: m.]". at org.geotools.referencing.operation.AbstractCoordinateOperationFactory.swapAndScaleAxis(AbstractCoordinateOperationFactory.java:278) at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1041) at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1136) at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:247) at org.geotools.referencing.operation.BufferedCoordinateOperationFactory.createOperation(BufferedCoordinateOperationFactory.java:254) at org.geotools.referencing.CRS.findMathTransform(CRS.java:1026) at org.geotools.referencing.CRS.findMathTransform(CRS.java:994) at gov.noaa.vdatum.App.<init>(App.java:34) at gov.noaa.vdatum.App.main(App.java:23) Caused by: java.lang.IllegalArgumentException: No source axis match GEOCENTRIC_X. at org.geotools.referencing.operation.matrix.GeneralMatrix.<init>(GeneralMatrix.java:314) at org.geotools.referencing.operation.matrix.GeneralMatrix.<init>(GeneralMatrix.java:221) at org.geotools.referencing.cs.AbstractCS.swapAndScaleAxis(AbstractCS.java:331) at org.geotools.referencing.operation.AbstractCoordinateOperationFactory.swapAndScaleAxis(AbstractCoordinateOperationFactory.java:276) ... 8 more I tried to debug the above example and got lost in the jungle of codes. Where did I go wrong? I know the geodetic/cartography algorithms to do coordinate transformations, however I don't know how to use Geotools to do so. Could you please show me the algorithms or in simple codes of how-to: 1. transform between two different coordinate systems (geographic, geocentric, UTM) of an input point. 2. transform between two datums, for example from NAD83(HARN) to ITRF2005 Thank you very much once again. ~ble -- View this message in context: http://n2.nabble.com/gt-referencing-questions-from-a-newbie-tp4294766p4294766.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users