java - (Geotools 库)如何转换韩国坐标(EPSG :5179) to Decimal Degree coordinates (EPSG:4326)

标签 java coordinates coordinate-systems geotools epsg

我在从韩国 2000 坐标系 (EPSG:5179) 转换为十进制度 (EPSG:4326) 时遇到问题。

我们正在为韩国公司开发地理信息系统。我们将 Geotools 库用于多个后端实现。但是,我现在遇到从 EPSG:5179 到 EPSG:4326 的转换问题。例如:当使用多个在线转换器时,如 https://epsg.io/transform#s_srs=5179&t_srs=4326 试图转换韩国坐标: x : 1307285 是:2229260

预期结果是(十进制格式): x : 131.0999928 是:40.0099722

所以现在我正在尝试使用 Geotools 库来使用此文档进行相同的转换 http://docs.geotools.org/stable/userguide/library/api/jts.html

我的示例测试:

public void testProjectedKoreanCoordinatesToDecimalDegree() throws FactoryException, TransformException {
    //EPSG:5179 -> EPSG:4326 CONVERSION

    CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:5179");
    CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");

    double coordinateX = 1307285;
    double coordinateY = 2229260;

    Coordinate in = new Coordinate(coordinateX, coordinateY);
    Coordinate out = in;

    MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
    Coordinate result = JTS.transform(in, out, transform);
    DegreeCoordinates degreeCoordinates = DegreeCoordinates.fromJTSCoordinate(result);

    double expectedLongitude = 131.0999928;
    double expectedLatitude = 40.0099721;

    assertEquals(expectedLongitude, degreeCoordinates.getLongitude(), 0.00001);
    assertEquals(expectedLatitude, degreeCoordinates.getLatitude(), 0.00001);
}

所以第一次坐标比较时测试失败,实际输出为: 经度:140.340217725

当经度应该是131.0999928

你对我做错了什么有什么建议吗?提前谢谢你!

最佳答案

这是一个典型的(程序员)错误,您假设您的坐标是 X-Y 或东西北顺序。但是,如果您查看 EPSG:5179 的定义,您会看到:

PROJCS["Korea 2000 / Unified CS", 
  GEOGCS["Korea 2000", 
    DATUM["Geocentric datum of Korea", 
      SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY["EPSG","7019"]], 
      TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 
      AUTHORITY["EPSG","6737"]], 
    PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Geodetic latitude", NORTH], 
    AXIS["Geodetic longitude", EAST], 
    AUTHORITY["EPSG","4737"]], 
  PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]], 
  PARAMETER["central_meridian", 127.5], 
  PARAMETER["latitude_of_origin", 38.00000000000001], 
  PARAMETER["scale_factor", 0.9996], 
  PARAMETER["false_easting", 1000000.0], 
  PARAMETER["false_northing", 2000000.0], 
  UNIT["m", 1.0], 
  AXIS["Northing", NORTH], 
  AXIS["Easting", EAST], 
  AUTHORITY["EPSG","5179"]]

它的坐标是 North-East 或 y-x,所以如果您将代码修改为:

Coordinate in = new Coordinate(coordinateY, coordinateX); 

你会得到正确答案,我得到 (40.00997217325207 131.0999927804759)

关于java - (Geotools 库)如何转换韩国坐标(EPSG :5179) to Decimal Degree coordinates (EPSG:4326),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54362007/

相关文章:

java - 将地球上由 4 个纬度经度坐标给出的区域分割成等距网格?

java - Vert.x 从 TCP 的部分字节读取

java - 如何在tomcat中部署的不同Web应用程序中访问公共(public)jar中加载的bean

objective-c - 如何在 Xcode 的 UIImageView 中获取 UIImage 坐标(x,y,width,height)

r - 在R中如何将经度和纬度转换为可在ggplot2或ggmap中使用的格式

mysql - 如何在相等的桶中按距离排序?

java - 如何通过连接到 JSP 的 servlet 插入带有 auto_increment 外键的 MySQL 表

java - 有关Java TV API的指南

3d - 使用水平和垂直角度和斜距计算 3D 点坐标

java - 如何使用 JMapProjLib、Proj4j 或 Proj4js 在不同坐标系之间转换坐标?