2

I'd like to reproject point that is in local coordinate system to the WGS84, using gdal. But exception "No PROJ.4 translation for source SRS, coordinate transformation initialization has failed" appears. Unfortunately, I've no idea how to proceed with the issue. Here is my code on c#

            Gdal.AllRegister();
            Dataset dataset = Gdal.Open(@"D:\TifExample\raster.tif", Access.GA_ReadOnly);
            String WKTFromTif = dataset.GetProjectionRef();

            Double[] gt = new double[6];
            dataset.GetGeoTransform(gt);
            Int32 Rows = dataset.RasterYSize; 
            Int32 Cols = dataset.RasterXSize;
            Double upperLeftX = gt[0];
            Double upperLeftY = gt[3];
            Double lowerRightX = gt[0] + Cols * gt[1] + Rows * gt[2];
            Double lowerRightY = gt[3] + Cols * gt[4] + Rows * gt[5];

            Double[] upperLeftPoint = { upperLeftX, upperLeftY };
            Double[] lowerRightPoint = { lowerRightX, lowerRightY };

            SpatialReference currentSpatialReference = new SpatialReference(WKTFromTif);

            String EPSG4326WKT = "GEOGCS[\"WGS84 datum, Latitude-Longitude; Degrees\", DATUM[\"WGS_1984\", SPHEROID[\"World Geodetic System of 1984, GEM 10C\",6378137,298.257223563, AUTHORITY[\"EPSG\",\"7030\"]], AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\",0], UNIT[\"degree\",0.0174532925199433], AUTHORITY[\"EPSG\",\"4326\"]]";
            SpatialReference newSpatialReference = new SpatialReference(EPSG4326WKT);

            CoordinateTransformation coordinateTransform = new CoordinateTransformation(currentSpatialReference, newSpatialReference);

            coordinateTransform.TransformPoint(upperLeftPoint);
            coordinateTransform.TransformPoint(lowerRightPoint);

P.S. WKTFromTif has next value for my raster :"LOCAL_CS[\"WGS 84 / Pseudo-Mercator\",GEOGCS[\"WGS 84\",DATUM[\"unknown\",SPHEROID[\"unretrievable - using WGS84\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],AUTHORITY[\"EPSG\",\"3857\"],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]]]"

Does anyone knows how to solve the problem?

Here is the data from gdalinfo

PROJCS["WGS 84 / Pseudo-Mercator",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +
x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs"],
    AUTHORITY["EPSG","3857"]]
Origin = (4042799.739385183900000,6382762.252179093700000)
8
  • The local CS is identifed ad Pseudo Mercator, centered by default off the Nigerian coast. This would be identical to EPSG:3857. I would expect a local CS to have an origin close to the study area. can you run gdalinfo on the file, and report the extent, and where you expect the data?
    – AndreJ
    Commented Apr 14, 2016 at 15:17
  • Information from gdalinfo were added above. Somehow it is different from WKTFromTif. Why?In addition: Gdalinfo shows expected result (projected coordinate system EPSG:3857). Commented Apr 14, 2016 at 15:55
  • So you just want to reporject from EPSG:3857 to EPSG:4326. That should be a pretty simple task, see stackoverflow.com/questions/27131981/gdal-warping-in-c-sharp and gis.stackexchange.com/questions/20060/…
    – AndreJ
    Commented Apr 14, 2016 at 16:54
  • Yes, your are right, reprojecting from EPSG:3857 to EPSG:4326 is simple task, but this is good decision just for this particular case. Actually, I don't have an information about projection of input *.tif in advance and I can get it only from method GetProjectionRef(). But, unfortunately, transformation doesn't work at all with the data returned by the method. So, the question is still open: How to make transformation using WKT from GetProjectionRef()? Commented Apr 15, 2016 at 9:23
  • Have you tried the query method from gdal.org/osr_tutorial.html?
    – AndreJ
    Commented Apr 15, 2016 at 11:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.