gpt4 book ai didi

java - Geotools坐标变换

转载 作者:行者123 更新时间:2023-12-01 12:49:41 24 4
gpt4 key购买 nike

如何将 EPSG: 54003 中的坐标转换为 EPSG:4326?我使用以下代码

 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com