<div dir="ltr"><div><div><div><div><div><div><div>Dear friends,<br></div>                   I have to programmatically clip (using Visual C++) with GDALWarp. I proceeded like this:<br><br></div><div>GDALDataset *outimg;<br></div><div><br></div><div>outimg->(GDALDataset *) GDALOpen(filename, GA_Update);<br></div><div>/* I also tried, instead of the above, outimg=driver->Create(filename, NewCol, NewRow, Band, DataType, NULL); */ <br></div><div><br></div></div>GDALWarpOptions *WO=GDALCreateWarpOptions( );<br><br>if(WO)<br>{<br>  WO->hSrcDS=inimg; WO->nBandCount=Band; <br>  <br>  WO->hDstDS=(GDALDatasetH)(outimg); WO->hCutline=myshp;<br><br>  WO->panSrcBands=(int *) CPLMalloc(sizeof(int)*Band); WO->panSrcBands[0]=Band;<br>  WO->panDstBands=(int *) CPLMalloc(sizeof(int)*Band); WO->panDstBands[0]=Band;<br><br>  WO->pfnProgress=GDALTermProgress;<br><br>  GDALWarpOperation *operation=new GDALWarpOperation;<br><br>  if(operation)<br>  {<br>    operation->Initialize(WO);<br>    operation->ChunkAndWarpImage(0, 0, NewCol, NewRow);<br>    <br>    GDALDestroyWarpOptions(WO); WO=NULL; delete operation; operation=NULL;<br>    <br>   }<br><br>   GDALClose((GDALDatasetH) outimg); outimg=NULL;<br>   <br>  }  <br><br></div>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. <br><br>How to overcome these problems? Are there any additional issues in the code?<br><br></div>                                                                                                       With many thanks,<br><br></div>                                                                                                       Yours sincerely,<br></div>                                                                                                          B. Ramesh<br><div><div><div><div><div><div><div><br></div></div></div></div></div></div></div></div>