Skip to main content
1 of 3
weliam
  • 357
  • 1
  • 9

Problems with gdal1.8 Java bindings gdal.ReprojectImage, pruduces no data

I have a problem with the gdal.ReprojectImage from gdal1.8 Java bindings. When I perform the reprojection, the projected image is totally black. And the origin of the projected image is wrong too. There were no error popping up at all. The code is as following:

           Dataset in_ds = gdal.Open(inPath, gdalconst.GA_ReadOnly);
           Dataset out_ds = in_ds.GetDriver().Create(outPath,in_ds.getRasterXSize(), in_ds.getRasterYSize(), in_ds.getRasterCount());

           try {
                   SpatialReference dstRef = new SpatialReference("");
                   dstRef.ImportFromEPSG(26919);

                   out_ds.SetProjection(dstRef.ExportToWkt());
                   out_ds.SetGeoTransform(in_ds.GetGeoTransform());

                   if (gdal.ReprojectImage(in_ds, out_ds) == gdalconst.CE_Failure)
                           System.out.println("something is wrong");
           } finally {
                   in_ds.delete();
                   out_ds.delete();
           }

Does anybody know what's going on here? Thanks a lot.

weliam
  • 357
  • 1
  • 9