Projecting a raster with a datum transformation
When projecting raster data, you can specify a geotransformation if the spatial references of the input and output are based on different datums. See the following code example:
[Java]
static void projectRasterWithDatumTransformation(IRasterDataset2 rasterDataset,
ISpatialReference outSR, int geoTrans)throws Exception{
//This examples shows how to specify a datum transfomration when projecting raster data
//rasterDataset: represents input a raster dataset that has a known spatial reference
//outSR: represents the spatial reference of the output raster dataset
//geoTrans: reprepresents the geo transformation between the input and output spatial reference
//set output spatial reference
IRaster raster = rasterDataset.createFullRaster();
IRasterProps rasterProps = new IRasterPropsProxy(raster);
rasterProps.setSpatialReference(outSR);
//spacify the geo transformation
ISpatialReferenceFactory2 srFactory = new SpatialReferenceEnvironment();
IGeoTransformation geoTransformation = (IGeoTransformation)
srFactory.createGeoTransformation(geoTrans);
//Add to the geo transformation operation set
IGeoTransformationOperationSet operationSet = new GeoTransformationOperationSet()
;
operationSet.set(esriTransformDirection.esriTransformForward, geoTransformation);
operationSet.set(esriTransformDirection.esriTransformReverse, geoTransformation);
//set the geotransformation on the Raster
IRaster2 raster2 = new IRaster2Proxy(raster);
raster2.setGeoTransformationsByRef(operationSet);
//save the result
ISaveAs saveas = new ISaveAsProxy(raster);
saveas.saveAs("c:/temp/outputRaster.img", null, "IMAGINE Image");
}
Development licensing | Deployment licensing |
---|---|
ArcInfo | ArcInfo |
ArcEditor | ArcEditor |
ArcView | ArcView |
Engine Developer Kit | Engine Runtime |