如何在EPSG:4326中从EPSG:54003转换坐标?
我使用以下代码

 CoordinateReferenceSystem WORLDCRS = DefaultGeographicCRS.WGS84;
 String wkt = "PROJCS[\"World_Miller_Cylindrical\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Miller_Cylindrical\"],PARAMETER[\"False_Easting\",0],PARAMETER[\"False_Northing\",0],PARAMETER[\"Central_Meridian\",0],UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"54003\"]]";
    CoordinateReferenceSystem crs;
    MathTransform transform;
    try
    {
        crs = crsFactory.createFromWKT(wkt);
        transform = CRS.findMathTransform(crs, WORLDCRS, true);
        System.out.println(transform.toWKT());
        System.out.println(transform.getClass().getCanonicalName());
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    try
    {
        transform = CRS.findMathTransform(CRS.decode("EPSG:54003"), WORLDCRS, true);
        System.out.println(transform.toWKT());
        System.out.println(transform.getClass().getCanonicalName());
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    try
    {
        transform = CRS.findMathTransform(CRS.decode("ESRI:54003"), WORLDCRS, true);
        System.out.println(transform.toWKT());
        System.out.println(transform.getClass().getCanonicalName());
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }`


在pom中,设置依赖项

<dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-epsg-extension</artifactId>
        <version>11.1</version>
        <scope>compile</scope>
    </dependency>


回应接收

org.opengis.referencing.NoSuchIdentifierException: No transform for classification "Miller_Cylindrical".
at org.geotools.referencing.operation.DefaultMathTransformFactory.getProvider(DefaultMathTransformFactory.java:290)
at org.geotools.referencing.operation.DefaultMathTransformFactory.getDefaultParameters(DefaultMathTransformFactory.java:316)
at org.geotools.referencing.wkt.Parser.parseProjection(Parser.java:603)
at org.geotools.referencing.wkt.Parser.parseProjCS(Parser.java:917)
at org.geotools.referencing.wkt.Parser.parseCoordinateReferenceSystem(Parser.java:225)
at org.geotools.referencing.wkt.Parser.parseCoordinateReferenceSystem(Parser.java:204)
at org.geotools.referencing.factory.ReferencingObjectFactory.createFromWKT(ReferencingObjectFactory.java:1090)
at ru.oogis.bank.sxf.TestCRS.main(TestCRS.java:25)
org.opengis.referencing.FactoryException: Error in "PROJECTION": No transform for classification "Miller_Cylindrical".
at org.geotools.referencing.factory.PropertyAuthorityFactory.createCoordinateReferenceSystem(PropertyAuthorityFactory.java:399)
at org.geotools.referencing.factory.BufferedAuthorityFactory.createCoordinateReferenceSystem(BufferedAuthorityFactory.java:783)
at org.geotools.referencing.factory.FallbackAuthorityFactory.createCoordinateReferenceSystem(FallbackAuthorityFactory.java:644)
at org.geotools.referencing.factory.FallbackAuthorityFactory.createCoordinateReferenceSystem(FallbackAuthorityFactory.java:644)
at org.geotools.referencing.factory.FallbackAuthorityFactory.createCoordinateReferenceSystem(FallbackAuthorityFactory.java:644)
at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:801)
at org.geotools.referencing.factory.ThreadedAuthorityFactory.createCoordinateReferenceSystem(ThreadedAuthorityFactory.java:731)
at org.geotools.referencing.DefaultAuthorityFactory.createCoordinateReferenceSystem(DefaultAuthorityFactory.java:179)
at org.geotools.referencing.CRS.decode(CRS.java:519)
at org.geotools.referencing.CRS.decode(CRS.java:447)
at ru.oogis.bank.sxf.TestCRS.main(TestCRS.java:36)
Caused by: java.text.ParseException: Error in "PROJECTION": No transform for classification "Miller_Cylindrical".
at org.geotools.referencing.wkt.Parser.parseProjection(Parser.java:605)
at org.geotools.referencing.wkt.Parser.parseProjCS(Parser.java:917)
at org.geotools.referencing.wkt.Parser.parseCoordinateReferenceSystem(Parser.java:225)
at org.geotools.referencing.wkt.Parser.parseCoordinateReferenceSystem(Parser.java:204)
at org.geotools.referencing.factory.PropertyAuthorityFactory.createCoordinateReferenceSystem(PropertyAuthorityFactory.java:396)
... 10 more
Caused by: org.opengis.referencing.NoSuchIdentifierException: No transform for classification "Miller_Cylindrical".
at org.geotools.referencing.operation.DefaultMathTransformFactory.getProvider(DefaultMathTransformFactory.java:290)
at org.geotools.referencing.operation.DefaultMathTransformFactory.getDefaultParameters(DefaultMathTransformFactory.java:316)
at org.geotools.referencing.wkt.Parser.parseProjection(Parser.java:603)
... 14 more
org.opengis.referencing.NoSuchAuthorityCodeException: Authority "ESRI" is unknown or doesn't match the supplied hints. Maybe it is defined in an unreachable JAR file?
at org.geotools.referencing.factory.ManyAuthoritiesFactory.noSuchAuthority(ManyAuthoritiesFactory.java:489)
at org.geotools.referencing.factory.ManyAuthoritiesFactory.getAuthorityFactory(ManyAuthoritiesFactory.java:467)
at org.geotools.referencing.factory.ManyAuthoritiesFactory.getCRSAuthorityFactory(ManyAuthoritiesFactory.java:548)
at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:801)
at org.geotools.referencing.factory.ThreadedAuthorityFactory.createCoordinateReferenceSystem(ThreadedAuthorityFactory.java:731)
at org.geotools.referencing.DefaultAuthorityFactory.createCoordinateReferenceSystem(DefaultAuthorityFactory.java:179)
at org.geotools.referencing.CRS.decode(CRS.java:519)
at org.geotools.referencing.CRS.decode(CRS.java:447)
at ru.oogis.bank.sxf.TestCRS.main(TestCRS.java:46)


是否有ESRI:54003 CRS代码?

最佳答案

您的GeoTools不知道ESRI:54003 CRS。
您需要改用EPSG:54003或其他CRS。

关于java - Geotools坐标变换,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24327420/

10-09 03:40