4

I am running into an interesting bug where the wkt returned from dataset.getProjection() does not match the wkt returned from gdalinfo.

(simplified) code:

final Dataset dataset = gdal.open("<somefile>.tif")
...
String wkt = dataset.getProjection()

returns:

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

whereas running gdalinfo on the SAME file returns:

Driver: GTiff/GeoTIFF
Files: testRaster.tif
Size is 718, 720
Coordinate System is:
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 = (-15042794.839973239228129,8590031.386050270870328)
Pixel Size = (0.512485836989726,-0.512485836989726)
Metadata:
  AREA_OR_POINT=Area
  COLORSPACE=RGB
  COMPRESSION_RATE_TARGET=4
  VERSION=2
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (-15042794.840, 8590031.386) (135d 7'54.21"W, 60d50'37.46"N)
Lower Left  (-15042794.840, 8589662.396) (135d 7'54.21"W, 60d50'31.65"N)
Upper Right (-15042426.875, 8590031.386) (135d 7'42.31"W, 60d50'37.46"N)
Lower Right (-15042426.875, 8589662.396) (135d 7'42.31"W, 60d50'31.65"N)
Center      (-15042610.858, 8589846.891) (135d 7'48.26"W, 60d50'34.56"N)
Band 1 Block=718x2 Type=Byte, ColorInterp=Red
  NoData Value=0
Band 2 Block=718x2 Type=Byte, ColorInterp=Green
  NoData Value=0
Band 3 Block=718x2 Type=Byte, ColorInterp=Blue
  NoData Value=0
Band 4 Block=718x2 Type=Byte, ColorInterp=Alpha
  NoData Value=0

My question is: Why am i getting the "LOCAL_CS" value from the java api vs the PROJCS value from gdalinfo?

  • 1
    Matt, is GDAL_DATA properly set in your Java environment? – user10353 Jul 9 '15 at 15:06
  • Yes, in both instances '/usr/local/share/gdal' . i even went and hardcoded the value into the run configuration (thinking intelliJ may have been having issues) but no such luck. – Matt Jul 9 '15 at 18:32
  • Could you make a small sample image which could be used for testing? – user30184 Jul 16 '15 at 19:53
1

For Internet People in the Future:

an ubuntu upgrade had interfered with the source-built gdal install. i am unsure what exactly was being referenced wrong, but removing the repo gdal package and rebuilding gdal seems to have removed the error.

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.