4

I have a problem when converting from Korean 2000 Coordinates System (EPSG:5179) to Decimal Degree (EPSG:4326).

We are developing Geographical Information System for Korean company. We were using Geotools library for mulitiple backend implementations. However I have problem now with conversion from EPSG:5179 to EPSG:4326. For example: when using multiple online converters like https://epsg.io/transform#s_srs=5179&t_srs=4326 trying to to convert korean coordinate: x : 1307285 y : 2229260

an expected results are (in decimal degree format): x : 131.0999928 y : 40.0099722

So now i'm trying to use Geotools library to do same convertion using this documentation http://docs.geotools.org/stable/userguide/library/api/jts.html

My example test:

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);
}

So that test fails at first coordinate comparison, actual output is: longitude : 140.340217725

when longitude should be 131.0999928

Do you have any suggestion what i am doing wrong ? Thank you in advance !

1 Answers1

2

This is a classic (programmer) mistake, you have assumed that your coordinates are in X-Y or East-North order. But if you look at the definition of EPSG:5179 you will see:

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"]]

that its coordinates are North-East or y-x so if you modify your code to be:

Coordinate in = new Coordinate(coordinateY, coordinateX); 

you will get the correct answer, I get (40.00997217325207 131.0999927804759).

Ian Turton
  • 10,018
  • 1
  • 28
  • 47