[GIS] Coordinate Transformation in Gdal/Ogr (EPSG:4326 to EPSG:3068)

coordinate systemepsggdalogrproj

I think gdal/ogr(/proj4) doesn't recognize epsg:3068 right?

Here is what I tried:

public static void transformSRS(){
        // creating EPSG:4326
        SpatialReference sourceSRS = new SpatialReference();
        sourceSRS.ImportFromEPSG(4326);
        // creating EPSG:3068
        SpatialReference targetSRS = new SpatialReference();
        sourceSRS.ImportFromEPSG(3068);
        // printing both SRS's
        System.out.println(sourceSRS); // does get printed
        System.out.println(targetSRS); // doesn't get printed!?
        // creating a point in EPSG:3068 coordinates 850,-150
        Geometry point = Geometry.CreateFromWkt("POINT(850 -150)");
        // assigning EPSG:3068 to the point so the system knows that it is in EPSG:3068
        point.AssignSpatialReference(sourceSRS);
        // trying to transform it to EPSG:4326 but Exception occurs.
        point.TransformTo(targetSRS);
}

and this is the output (first System.out.println() is working but the second one prints null and than the exception at point.TransformTo(targetSRS) ):

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

ERROR 6: No translation for an empty SRS to PROJ.4 format is known.
Exception in thread "main" java.lang.RuntimeException: OGR Error: General Error
    at org.gdal.ogr.ogrJNI.Geometry_TransformTo(Native Method)
    at org.gdal.ogr.Geometry.TransformTo(Geometry.java:409)
    at org.geotools.mavenGdal.Test.transformSRS(Test.java:880)
    at org.geotools.mavenGdal.Test.main(Test.java:109)

Best Answer

You can test it with gdalsrsinfo http://www.gdal.org/gdalsrsinfo.html

gdalsrsinfo epsg:3068

PROJ.4 : '+proj=cass +lat_0=52.41864827777778 +lon_0=13.62720366666667 +x_0=40000 +y_0=10000 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.45
5,6.7 +units=m +no_defs '

OGC WKT :
PROJCS["DHDN / Soldner Berlin",
    GEOGCS["DHDN",
        DATUM["Deutsches_Hauptdreiecksnetz",
            SPHEROID["Bessel 1841",6377397.155,299.1528128,
                AUTHORITY["EPSG","7004"]],
            TOWGS84[598.1,73.7,418.2,0.202,0.045,-2.455,6.7],
            AUTHORITY["EPSG","6314"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4314"]],
    PROJECTION["Cassini_Soldner"],
    PARAMETER["latitude_of_origin",52.41864827777778],
    PARAMETER["central_meridian",13.62720366666667],
    PARAMETER["false_easting",40000],
    PARAMETER["false_northing",10000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","3068"]]

Another test is to convert coordinates with gdaltransform http://www.gdal.org/gdaltransform.html

gdaltransform -s_srs epsg:3068 -t_srs epsg:4326
850 -150
13.0512110820125 52.3246380119762 41.6757647842169

Conclusion: At least my GDAL does recognize EPSG:3068.