坐标变换

发布于 2024-08-09 22:47:03 字数 222 浏览 2 评论 0原文

Java 是否存在任何开源或“免费”库,我可以在其中执行从一个空间系统到另一个空间系统的坐标转换?

我发现了 Opengeo http://opengeo.org/ 但它是一个庞大而全面的库,适用于各种空间事物。

还有更小的东西存在吗?我需要从 MGA56 转换为 WGS84。

Do any open source or 'free' libraries exist for Java where i can perform coordinate transforms from one spatial system to another?

I found Opengeo http://opengeo.org/ but it's a huge and comprehensive library for all sorts of spatial things.

Does anything smaller exist? I need to convert from MGA56 to WGS84.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

dawn曙光 2024-08-16 22:47:04

我需要在 WGS84(GPS 投影)和 EPSG 27700(英国国家电网)之间来回转换,我发现 geotrellis 库最准确、最可用。它是用 Scala 编写的,但显然您可以在 Java 中使用该库。这是我使用的 Maven 依赖项:

        <dependency>
            <groupId>org.locationtech.geotrellis</groupId>
            <artifactId>geotrellis-proj4_2.12</artifactId>
            <version>2.3.1</version>
        </dependency>

这是一些示例代码:

       CRS epsg27700 = CRS.fromEpsgCode(27700);
        CRS wgs84 = CRS.fromEpsgCode(4326);

        var toWgs84 = Transform.apply(epsg27700, wgs84);
        var fromWgs84 = Transform.apply(wgs84, epsg27700);

        Tuple2<Object, Object> southWestInWgs84 = toWgs84.apply(-90_619.29, 10_097.13);
        System.out.println("South-West corner in WGS 84: " + southWestInWgs84._1() + "," + southWestInWgs84._2());
        Tuple2<Object, Object> southWestBackToEpsg27700 = fromWgs84.apply(southWestInWgs84._1(), southWestInWgs84._2());
        System.out.println("South-West corner back to EPSG 27700: " + southWestBackToEpsg27700._1() + "," + southWestBackToEpsg27700._2());

它会产生以下输出:

WGS 84 中的西南角:-8.820000046234389,49.7899999643445

西南角返回 EPSG 27700:
-90619.2888566542,10097.128186725415

I've needed to convert back and forwards between WGS84 (the GPS projection) and EPSG 27700 (UK National Grid) and I've found the geotrellis library most accurate and usable. It's written in Scala but obviously you can use the library in Java. Here's the maven dependency I've used:

        <dependency>
            <groupId>org.locationtech.geotrellis</groupId>
            <artifactId>geotrellis-proj4_2.12</artifactId>
            <version>2.3.1</version>
        </dependency>

and this is some example code:

       CRS epsg27700 = CRS.fromEpsgCode(27700);
        CRS wgs84 = CRS.fromEpsgCode(4326);

        var toWgs84 = Transform.apply(epsg27700, wgs84);
        var fromWgs84 = Transform.apply(wgs84, epsg27700);

        Tuple2<Object, Object> southWestInWgs84 = toWgs84.apply(-90_619.29, 10_097.13);
        System.out.println("South-West corner in WGS 84: " + southWestInWgs84._1() + "," + southWestInWgs84._2());
        Tuple2<Object, Object> southWestBackToEpsg27700 = fromWgs84.apply(southWestInWgs84._1(), southWestInWgs84._2());
        System.out.println("South-West corner back to EPSG 27700: " + southWestBackToEpsg27700._1() + "," + southWestBackToEpsg27700._2());

which produces this output:

South-West corner in WGS 84: -8.820000046234389,49.7899999643445

South-West corner back to EPSG 27700:
-90619.2888566542,10097.128186725415

天煞孤星 2024-08-16 22:47:03

有一个完全用 Java 编写的轻量级库。

坐标变换套件(缩写 CTS)是一个为使用众所周知的大地测量算法和参数集执行坐标变换而开发的库。

CTS 处理 4257 个坐标参考系统 (3910 EPSG)。

本项目源码位于:

https://github.com/irstv/CTS

There is a lightweight library written fully in Java.

Coordinate Transformation Suite (abridged CTS) is a library developed to perform coordinate transformations using well known geodetic algorithms and parameter sets.

CTS handles 4257 coordinate reference systems (3910 EPSG).

The source code of this project is located at:

https://github.com/irstv/CTS

喜爱纠缠 2024-08-16 22:47:03

一个简单的解决方案是 PROJ.4,但它没有 Java 绑定,因此可以使用它可能有点棘手。更完整(但可能比您想要的更大)的解决方案是 GeoTools。但快速搜索发现了Java Map Projection Library,它似乎是一个Java PROJ.4 的端口。我会尝试一下。

由于看来您需要进行基准平移,而不仅仅是投影,因此您将需要某种坐标系数据库。最容易获得的是 EPSG 数据库——PROJ.4 附带了一个 EPSG 映射文件,该文件对于大多数用途来说应该足够了。

看起来 MGA56 是 EPSG:28356,当然 WGS84 是 EPSG:4326

A simple solution is PROJ.4, but it doesn't have Java bindings, so working with it might be a bit tricky. A more complete (but probably bigger than you want) solution would be GeoTools. But a quick search found the Java Map Projection Library, which appears to be a Java port of PROJ.4. I would give that a try.

Since it appears you need to do a datum shift, not only a projection, you will need to have some kind of coordinate system database. The easiest to get a hold of is the EPSG database -- PROJ.4 comes with an EPSG mapping file, which should be good enough for most purposes.

It looks like MGA56 is EPSG:28356, and of course WGS84 is EPSG:4326.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文