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
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to