Jesse, i believe I've run into this before. The GDALWarpOptions has a member, padfDstNoDataReal. It is an array of doubles nBands in size. Create that, fill it in with your no data values and set the Warp Option INIT_DEST to NO_DATA:
.... psWarpOptions = GDALCreateWarpOptions(); int nBandCount = srcDS->GetRasterCount(); psWarpOptions->nBandCount = nBandCount; psWarpOptions->padfDstNoDataReal = (double*) CPLMalloc( sizeof( double ) * nBandCount ); double dfNoData = -9999.0; for( int b = 0;b < srcDS->GetRasterCount();b++ ) { psWarpOptions->padfDstNoDataReal[b] = dfNoData; } psWarpOptions->papszWarpOptions = CSLSetNameValue( psWarpOptions->papszWarpOptions, "INIT_DEST", "NO_DATA" ); wrpDS = (GDALDataset*) GDALAutoCreateWarpedVRT( srcDS, pszSrcWkt, pszDstWkt, GRA_NearestNeighbour, 1.0, psWarpOptions ); ... That seemed to work for me, hopefully it puts you on the right track. kss On Mon, Jun 10, 2013 at 6:17 PM, Jesse Crocker <je...@gaiagps.com> wrote: > Hello List, > Im having some trouble with the C api, that I assume is do my failure to > understand some part of it. > What I'm trying to do: Load a BSB raster file, apply a cutline to the file, > and warp it into a north-up projection. Im doing additional transformations > to it after that, but right now I'm stuck trying to get areas outside of the > cutline to be transparent instead of black. > > An abbreviated version of what I'm doing now: > > sourceDataset = GDALOpen(imageFilePath.UTF8String, GA_ReadOnly ); > GDALWarpOptions *warpOptions = GDALCreateWarpOptions(); > OGRGeometryH clipGeometry; > OGRErr polyStatus = OGR_G_CreateFromWkt(&pszWkt, spatialRef, > &clipGeometry); > if(polyStatus == CE_None) { > warpOptions->hCutline = clipGeometry; > } > warpedDataset = GDALAutoCreateWarpedVRT(sourceDataset, > NULL, > NULL, > GRA_NearestNeighbour, > 0.0, > warpOptions); > > The source data does not have a no data value, i've tried setting one and > adding an entry to the color palette before calling GDALAutoCreateWarpedVRT, > and settings the same value in the VRT but that had no effect. > > Any suggestions for the right way to do this? Am I just setting the no_data > value incorrectly, or is this a situation that requires a mask band? And if > it does require a mask band is there an easy way to create that from a > cutline? > > Thanks, > Jesse > > _______________________________________________ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev