chrisb_b

Reprojection while loading Rasters

Discussion created by chrisb_b on Sep 10, 2010
Latest reply on Sep 10, 2010 by EinBerliner
I'm loading rasters into a file geodatabase in Engine code.  Some of them need reprojecting so I'm trying the following code:

// I have an IRaster pointed to by pRaster and a required ISpatialReference pointed to by pSpatialRef

VARIANT vMissing;
vMissing.vt = VT_ERROR;
vMissing.scode = DISP_E_PARAMNOTFOUND;

// Create a RasterTransformionOp to do the re-projection
CComPtr<ITransformationOp> pTransform;
hr = pTransform.CoCreateInstance(CLSID_RasterTransformationOp);

// get the IGeoDataset of the original Raster
CComPtr<IGeoDataset> pInGeoDataset;
hr = pRaster.QueryInterface(&pInGeoDataset);

// Project it into the new Spatial Reference
CComPtr<IGeoDataset> pOutGeoDataset;
hr = pTransform->ProjectFast(pInGeoDataset, pSpatialRef, esriGeoAnalysisResampleCubic, &vMissing, &pOutGeoDataset);
       
// Get the resulting RasterDataset
CComPtr<IRasterDataset> pReprojRasterDataset;
hr = pOutGeoDataset.QueryInterface(&pReprojRasterDataset);

// Get the reprojected raster from the new dataset
CComPtr<IRaster> pReprojRaster;
hr = pReprojRasterDataset->CreateDefaultRaster(&pReprojRaster);

// Load it into the existing File Geodatabase
hr = pRasterLoader->Load(pRasterDataset, pReprojRaster);


However, the resultant raster isn't reprojected.  Any clues as to what I am mis-understanding?

Chris

Outcomes