[gdal-dev] Re: reg GDALPolygonize
srikanth1947 at gmail.com
Wed Nov 18 04:11:05 EST 2009
I have found the solution myself.
Below is the piece of code for polygonizing the raster.
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.
Any help/suggestions are appreciated.
String pszFilename = "C:\\Images\\s3dImages\\geo_liss.tif";
poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly );
GDALRasterBand *poBandR,*poBandMask ;
poBandR = poDataset->GetRasterBand(1);
poBandMask = poBandR->GetMaskBand() ;
const char *pszDriverName = "ESRI Shapefile";
OGRDataSource* ds = poDriver->CreateDataSource("Shape", NULL );
OGRLayer* poLayer = ds->CreateLayer("myfile",NULL,wkbMultiPolygon,NULL);
CPLErr er = GDALPolygonize(poBandR , poBandMask , poLayer
On Mon, Nov 16, 2009 at 3:27 PM, Srikanth <srikanth1947 at gmail.com> wrote:
> Dear All ,
> I am trying to convert a raster to vector using GDALPolygonize function .
> Below is the code I am using
> String pszFilename = "C:\\Images\\image.tiff";
> poDataset = (GDALDataset *) GDALOpen( pszFilename , GA_ReadOnly );
> GDALRasterBand *poBandR,*poBandG,*poBandB;
> poBandR = poDataset->GetRasterBand(1);
> OGRLayer* poLayer;
> GDALPolygonize(poBandR , NULL , poLayer ,1,NULL,NULL,NULL);
> The process is crashed in the polygonize function. I wonder what might be
> wrong with the above. (or should I assign memory to OGRLayer ?)
> Any suggestions/examples regarding the same are appreciated.
> Srikanth K.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gdal-dev