<div><br clear="all">Hi Group,</div><div> </div><div>I just encountered an error in writting data to image in GTiff format using the OSGeo.GDAL.Gdal.Open command. The error message showing is "****.tif not recognised as a supported file format". The gdal librarary I am using is gdal19dev.dll. The weird thing is the Gdal.Open command worked if the image is in the format of HFA. The C# code I used to implement the writting process is attached below (the sentence where error happened was highlighted in red):</div>
<div>         /// <summary><br>        /// Function of  WriteData2File<br>        /// </summary><br>        /// <param name="LCx">the column index of left corner</param><br>        /// <param name="LCy">the row index of left corner</param><br>
        /// <param name="width">the width of the rectangle</param><br>        /// <param name="height">the length of the rectangle</param><br>        /// <param name="fileName">the fileName where the data will be saved</param><br>
        /// <returns>true, if the data is added correctly, false otherwise.</returns></div><div>        public bool WriteData2File(int LCx, int LCy, int width, int height, int band, byte[] Data, string fileName)<br>
        {<br>            OSGeo.GDAL.Driver imgDriver = OSGeo.GDAL.Gdal.GetDriverByName("GTiff");<br>            string extension = System.IO.Path.GetExtension(fileName);<br>            if (extension == ".img")<br>
                imgDriver = OSGeo.GDAL.Gdal.GetDriverByName("HFA");<br>            if (imgDriver == null)<br>                throw new Exception("The file type is not supported!");<br>            // OSGeo.GDAL.Gdal.AllRegister();<br>
            <font color="#ff0000">OSGeo.GDAL.Dataset ds = OSGeo.GDAL.Gdal.Open(fileName, OSGeo.GDAL.Access.GA_Update);</font><br>            int[] bandMap = new int[] { 1, 1, 1, 1 };<br>            try<br>            {<br>
                ds.WriteRaster(LCx, LCy, width, height, Data, width, height, 1, bandMap, 0, 0, 0);<br>                //ds.WriteRaster(LCx, LCy, width, height, Data, width, height, band, 0, 0, 0);<br>                ds.Dispose();<br>
                return true;<br>            }<br>            catch<br>            {<br>                return false;<br>            }<br>        }</div><div> </div><div>Can anyone point out where the problem is? Thank you so much,</div>
<div> </div><div><br>-- <br></div><div>Zhenyu Lu</div>
<div>SUNY-ESF</div><br>