首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java:将经度从EPSG:4236转换为EPSG: 3857

Java:将经度从EPSG:4236转换为EPSG: 3857
EN

Stack Overflow用户
提问于 2013-03-25 07:11:47
回答 1查看 6.4K关注 0票数 4

如何使用geotools或其他java库将我的经纬度转换为EPSG 3857投影?我很难找到合适的方法来使用。我知道OpenLayers (javascript)可以很容易地做到这一点,但我看不到转换这些坐标的清晰路径。

代码语言:javascript
复制
I would like to see this transformation
source lon, lat: -71.017942,  42.366662    
destination lon, lat: -71 1.25820, 42 22.0932

所以我已经创建了我的CRS

代码语言:javascript
复制
final CoordinateReferenceSystem source = CRS.decode( "EPSG:4236" );
final CoordinateReferenceSystem dest = CRS.decode("EPSG:3857");

final MathTransform transform = CRS.findMathTransform(source, dest);

但是创建几何图形似乎并不是直接使用这些点,因为它们需要一个几何工厂或其他什么东西。

我是地理工具和地理空间数据的新手,感谢您的指点。

EN

回答 1

Stack Overflow用户

发布于 2013-10-12 05:15:18

这是给你的解决方案:

代码语言:javascript
复制
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4236");
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3857");
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, false);
GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326);
Point point = geometryFactory.createPoint(new Coordinate(lon, lat));
Point targetPoint = (Point) JTS.transform(point, transform);
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15605247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档