1

I am converting tif+tfw to Geotiff using GDAL C#, below is the sample code. I can able to handle the color images with Band 1, 2 and 3 tif images, but for the Black and white images which had no band values, it contains high and low values, it throws exception.

WriteEncodedTile/Strip() failed.

OSGeo.GDAL.Driver.CreateCopy(String utf8_path, Dataset src, Int32 strict, String[] options, GDALProgressFuncDelegate callback, String callback_data)

GdalConfiguration.ConfigureGdal();
                String[] options = { "COMPRESS=DEFLATE", "PREDICTOR=2" };

                string fileNamewithoutext = Path.GetFileNameWithoutExtension(fileSrcPath);



                //Gdal.AllRegister();
                OSGeo.GDAL.Driver srcDrv = Gdal.GetDriverByName("GTiff");
                outputfile = txtSelectOutput.Text + "\\" + fileNamewithoutext + "_Georefereced.tif";
                Dataset srcDs = Gdal.Open(fileSrcPath, Access.GA_ReadOnly);
                Dataset dstDs = srcDrv.CreateCopy(outputfile, srcDs,1, options, null, null);

Your Answer

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

Browse other questions tagged or ask your own question.