[gdal-dev] A Problem with GDALWarp
user gdal
userofgdal at gmail.com
Wed Aug 19 03:31:32 PDT 2015
Dear friends,
I have to programmatically clip (using Visual C++) with
GDALWarp. I proceeded like this:
GDALDataset *outimg;
outimg->(GDALDataset *) GDALOpen(filename, GA_Update);
/* I also tried, instead of the above, outimg=driver->Create(filename,
NewCol, NewRow, Band, DataType, NULL); */
GDALWarpOptions *WO=GDALCreateWarpOptions( );
if(WO)
{
WO->hSrcDS=inimg; WO->nBandCount=Band;
WO->hDstDS=(GDALDatasetH)(outimg); WO->hCutline=myshp;
WO->panSrcBands=(int *) CPLMalloc(sizeof(int)*Band);
WO->panSrcBands[0]=Band;
WO->panDstBands=(int *) CPLMalloc(sizeof(int)*Band);
WO->panDstBands[0]=Band;
WO->pfnProgress=GDALTermProgress;
GDALWarpOperation *operation=new GDALWarpOperation;
if(operation)
{
operation->Initialize(WO);
operation->ChunkAndWarpImage(0, 0, NewCol, NewRow);
GDALDestroyWarpOptions(WO); WO=NULL; delete operation; operation=NULL;
}
GDALClose((GDALDatasetH) outimg); outimg=NULL;
}
The system quit the execution of the program just after
operation->Initialize (the Debug revealed so). The problem is with
WO->hDstDS(...). The outimg is surprisingly NULL though there are no
unusual characters in the 'filename'. I also tried to change outimg from
GDALDataset to GDALDatasetH, but to no advantage.
How to overcome these problems? Are there any additional issues in the code?
With many thanks,
Yours sincerely,
B. Ramesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150819/f65397de/attachment-0001.html>
More information about the gdal-dev
mailing list