Iclipfilter clipraster = New Clipfilterclass ();
// Add the polygons from the shapefile to the clip filer
Igeometry clipgeometry;
Ifeature feature;
For(IntI = 0; I <= featureclass. featurecount (Null)-1; I ++)
{
Feature = featureclass. getfeature (I );
Clipgeometry = (igeometry) feature. shape;
Clipraster. Add (clipgeometry );
}
// set the filter to the raster
ipixeloperation pixelop = (ipixeloperation) raster;
pixelop. pixelfilter = (ipixelfilter) clipraster;
// now we need to specify properties for the output. the output can
// be a file format or a Geodatabase. this sample supports output
// to file Geodatabase and personal Geodatabase.
// If the output is a file format and input raster does not contain nodata and the max value
// Of the pixel depth is being used. (for example 255 is used for
// 8 bit unsigned case ), output pixel depth needs to be promoted and nodata
// value need to set up properly.
Iworkspace workspace = openworkspace (outputfolder );
Irasterprops rasterprops = (irasterprops) raster;
If(Workspace. pathname. Contains (". GDB") =False)
{
Rasterprops. nodatavalue = 256;
Rasterprops. pixeltype = rstpixeltype. pt_ushort;
}
// Save the result out
Isaveas saveas = (isaveas) raster;
Saveas. saveas (outputfile, workspace, format );