This document is archived and information here might be outdated.  Recommended version.


How to georeference a raster using polynomial transformation (ArcObjects .NET 10.5 SDK)

How to georeference a raster using polynomial transformation


Summary
Georeferencing a raster using polynomial transformation is a common task. You can access this feature from the Georeferencing toolbar in ArcMap or use the Warp geoprocessing tool in the Data Management Tools toolbox. This topic shows how to georeference a raster using polynomial transformation programmatically.

Georeferencing a raster using polynomial transformation

The following subroutine defines a polynomial transformation from two sets of control points and applies the transformation to an input raster datasets in two ways:
[C#]
public static void GeoreferenceRaster(IRasterDataset2 rasterDataset,
    IPointCollection sourcePoints, IPointCollection targetPoints)
{
    // The sourcePoints represent source control points.
    // The targetPoints represent target control points.

    IRasterGeometryProc rasterPropc=new RasterGeometryProcClass();
    IRaster raster=rasterDataset.CreateFullRaster();

    //Set the transformation. The number of control points must meet the minimum requirements 
    //of the order of transformation. The first order polynomial must have at least 3 non-correlated 
    //points; the second order polynomial must have at least 6; and the third order must have at 
    //least 10 control points.

    rasterPropc.Warp(sourcePoints, targetPoints,
        esriGeoTransTypeEnum.esriGeoTransPolyOrder1, raster);

    //There are two ways to get the georeferenced result: Save the transformation with the 
    //input raster dataset,
    rasterPropc.Register(raster);

    //or save to another new raster dataset.
    rasterPropc.Rectify(@"c:\temp\georeferencing_output.img", "IMAGINE Image",
        raster);
}
[VB.NET]
Public Shared Sub GeoreferenceRaster(ByVal rasterDataset As IRasterDataset2, ByVal sourcePoints As IPointCollection, ByVal targetPoints As IPointCollection)
' The sourcePoints represent source control points.
' The targetPoints represent target control points.

Dim rasterPropc As IRasterGeomeTryProc=New RasterGeomeTryProcClass()
Dim raster As IRaster=rasterDataset.CreateDefaultRaster()

'Set the transformation.
rasterPropc.Warp(sourcePoints, targetPoints, esriGeoTransTypeEnum.esriGeoTransPolyOrder1, raster)

'There are two ways to get the georeferenced result: Save the transformation with the input
'raster dataset,

rasterPropc.Register(raster)

'or save to another new raster dataset.
rasterPropc.Rectify("c:\temp\georeferencing_output.img", "IMAGINE Image", raster)
End Sub






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Basic ArcGIS Desktop Basic
Engine Developer Kit Engine