0

I would like to achieve the same output as for GDAL using the GeoTools library:

    CoordinateReferenceSystem crs = CRS.decode("EPSG:32632");
    String wkt = crs.toWKT();
    System.out.println(wkt);

GeoTools output:

PROJCS["WGS 84 / UTM zone 32N", 
  GEOGCS["WGS 84", 
    DATUM["World Geodetic System 1984", 
      SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], 
      AUTHORITY["EPSG","6326"]], 
    PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Geodetic latitude", NORTH], 
    AXIS["Geodetic longitude", EAST], 
    AUTHORITY["EPSG","4326"]], 
  PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]], 
  PARAMETER["central_meridian", 9.0], 
  PARAMETER["latitude_of_origin", 0.0], 
  PARAMETER["scale_factor", 0.9996], 
  PARAMETER["false_easting", 500000.0], 
  PARAMETER["false_northing", 0.0], 
  UNIT["m", 1.0], 
  AXIS["Easting", EAST], 
  AXIS["Northing", NORTH], 
  AUTHORITY["EPSG","32632"]]

GDAL output:

PROJCS["WGS 84 / UTM zone 32N",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",9],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH],
    AUTHORITY["EPSG","32632"]]

There are some minor differences, including missing authority in some cases, indents, etc. For example,

GDAL:

    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],

GeoTools:

  UNIT["m", 1.0], 

Is is possible to tune GeoTools such that it outputs the same WKT as GDAL?

What are the other ways to print the same WKT output to GDAL but not using native GDAL libraries?

  • which GeoTools referencing module are you using? – Ian Turton Jul 10 '18 at 19:26
  • Also, does it really matter? They are functionally identical, that is all the numbers are the same – Ian Turton Jul 10 '18 at 19:26
  • Yes, this is important to me. I use GeoToools v18.0: gt-main, gt-epsg-hsql, gt-api from Maven – Antonio Jul 11 '18 at 8:06
0

I'm still no clear as to why the formatting of the WKT matters to you, but if you switch to the gt-epsg-wkt module you can edit the raw definition of your projection to match your requirements.

The indentation is a simple search and replace.

  • Will you kindly share any usage examples? – Antonio Jul 12 '18 at 19:26
  • examples of what? – Ian Turton Jul 12 '18 at 19:31
  • gt-epsg-wkt module. Is that just a list of WKT output for EPSG codes? – Antonio Jul 12 '18 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.