<div>Hi ,</div>
<div> </div>
<div>I have found the solution myself.</div>
<div>Below is the piece of code for polygonizing the raster.</div>
<div> </div>
<div>Yet there is another problem i am facing. I am unable to create a mask band for a particular pixel value.I understand that could be done using thresholding. But I did not find any method for that in GDAL.</div>
<div> </div>
<div>Any help/suggestions are appreciated.</div>
<div> </div>
<div><br>GDALAllRegister();</div>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">OGRRegisterAll();</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">String pszFilename = &quot;C:\\Images\\s3dImages\\geo_liss.tif&quot;;</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly );</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">GDALRasterBand *poBandR,*poBandMask ;</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">poBandR = poDataset-&gt;GetRasterBand(1);</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">poBandR-&gt;CreateMaskBand(GMF_PER_DATASET);</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">poBandMask = poBandR-&gt;GetMaskBand() ;</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">poBandMask-&gt;Fill(10,0);</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">const char *pszDriverName = &quot;ESRI Shapefile&quot;;</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">OGRSFDriver *poDriver;</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">poDriver = OGRSFDriverRegistrar::GetRegistrar()-&gt;GetDriverByName(pszDriverName);</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">OGRDataSource* ds = poDriver-&gt;CreateDataSource(&quot;Shape&quot;, NULL );</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">OGRLayer* poLayer = ds-&gt;CreateLayer(&quot;myfile&quot;,NULL,wkbMultiPolygon,NULL);</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">CPLErr er = GDALPolygonize(poBandR , poBandMask , poLayer ,1,NULL,NULL,NULL);</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">poLayer-&gt;SyncToDisk();</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-paragraph-type: empty"></p>
<div style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256">OGRDataSource::DestroyDataSource(ds);</div>
<div style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256"> </div>
<div style="MARGIN: 0px; TEXT-INDENT: 0px; -qt-block-indent: 0; -qt-user-state: 256"><br> </div>
<div class="gmail_quote">On Mon, Nov 16, 2009 at 3:27 PM, Srikanth <span dir="ltr">&lt;<a href="mailto:srikanth1947@gmail.com">srikanth1947@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Dear All ,</div>
<div> </div>
<div>I am trying to convert a raster to vector using GDALPolygonize function . Below is the code I am using<br clear="all"></div>
<div>GDALAllRegister(); 
<p style="MARGIN: 0px; TEXT-INDENT: 0px"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px">String pszFilename = &quot;C:\\Images\\image.tiff&quot;;</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px">poDataset = (GDALDataset *) GDALOpen( pszFilename , GA_ReadOnly );</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px">GDALRasterBand *poBandR,*poBandG,*poBandB;</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px">poBandR = poDataset-&gt;GetRasterBand(1);</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px">OGRLayer* poLayer;</p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px"></p>
<p style="MARGIN: 0px; TEXT-INDENT: 0px">GDALPolygonize(poBandR , NULL , poLayer ,1,NULL,NULL,NULL);</p></div>
<div> </div>
<div> </div>
<div>The process is crashed in the polygonize function. I wonder what might be wrong with the above. (or should I assign memory to OGRLayer ?) </div>
<div> </div>
<div>Any suggestions/examples regarding the same are appreciated.</div>
<div> </div><font color="#888888">
<div><br>-- <br>Regards,<br>Srikanth K.<br><br><br></div></font></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Srikanth K.<br><a href="http://www.servetheneedy.org">www.servetheneedy.org</a><br><br>