I'm testing a portion of a Desktop Add-In that uses a raster clip function to quickly clip a topo raster to a quadrangle polygon (Data management was far too slow as I will be clipping many rasters). Everything works fine except that the output raster has a bit of an overlap from the polygon extent. I have noticed in a PCS the overlap is uneven and in a GCS it is uniform.

When I use the Image Analysis window to clip the raster by selecting the quad polygon the output is perfectly flush and I'm wondering what my program is doing differently.

ArcGIS 10.1 SP1, C#.NET/4.0

    protected override void OnClick()
        mxdoc = ArcMap.Application.Document as IMxDocument;

        IWorkspaceFactory rwsf = new RasterWorkspaceFactoryClass();
        IWorkspaceFactory fwsf = new FileGDBWorkspaceFactoryClass();
        IRasterWorkspace rws = (IRasterWorkspace)rwsf.OpenFromFile(topoFolderPath, ArcMap.Application.hWnd);
        IRasterDataset rds = rws.OpenRasterDataset(topoBaseName);

        IFeatureLayer2 quadLayer2 = new FeatureLayerClass();
        IFeatureWorkspace fws = (IFeatureWorkspace)fwsf.OpenFromFile(quadFolderPath, ArcMap.Application.hWnd);
        quadLayer2.FeatureClass = fws.OpenFeatureClass(quadBaseName);
        IFeatureLayer quadLayer = (IFeatureLayer)quadLayer2;

        IClipFunctionArguments rasterFuncArgs = new ClipFunctionArguments() as IClipFunctionArguments;
        rasterFuncArgs.Raster = rds;
        rasterFuncArgs.ClippingType = esriRasterClippingType.esriRasterClippingOutside;
        rasterFuncArgs.ClippingGeometry = quadLayer.AreaOfInterest;

        IRasterFunction clipFunction = new ClipFunctionClass();
        IFunctionRasterDataset funcRasterDataset = new FunctionRasterDataset();
        IFunctionRasterDatasetName funcRasterDatasetName = new FunctionRasterDatasetName() as IFunctionRasterDatasetName;
        funcRasterDatasetName.FullName = @"C:\Users\dcanady\Desktop\clip.afr";
        funcRasterDataset.FullName = (IName)funcRasterDatasetName;
        funcRasterDataset.Init(clipFunction, rasterFuncArgs);

        rds = funcRasterDataset as IRasterDataset;
        IRasterLayer rLayer = new RasterLayerClass();
        mxdoc.AddLayer(rLayer as ILayer);

enter image description here

Above is the clip result behind the quad polygon I'd like it to be flush with (UTM 14) and a topo basemap layer.

2 Answers 2


Looking at your image the polygon does not appear to be a square aligned to the raster, it is ever so slighty rotated, so the output of the clip appears to be the extent of the polygon.

In your code your clipping geometry is set to the area of interest and not the geometry it self. This may explain the odd output, so I suggest you investigate that first.


Here's the code that I added to solve my problem:

IFeature QLFeature = quadLayer.FeatureClass.GetFeature(1); //quadLayer only has 1 OID
rasterFuncArgs.ClippingGeometry = QLFeature.Shape;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.