About handling multiband output
Some methods, such as Curvature, EucDistanceFull, CostDistanceFull, and FlowDirection, can return optional outputs from the operation. In these cases, the output Raster object contains more than one band. Each band in the output Raster points to a different output temporary dataset. The first band is the default output of the method and the bands are placed in the same order as they appear in the method signature.
To save each band as a separate raster dataset, use the IRasterBandCollection interface on the output Raster and individually access the bands. Once you have the individual bands, you can save them as permanent datasets. You can also save the output Raster as a multiband raster dataset.
The following code example shows how to access the second band and the profile curve from the results of the Curvature method:
[C#]
public IRaster GetSecondRaster(IRaster raster_ResultOfCurvature)
{
IRaster raster = null;
// Gets the second band of a multiband raster.
IRasterBandCollection rasterBandCollection = (IRasterBandCollection)
raster_ResultOfCurvature;
IRasterBand rasterBand = null;
IRasterDataset rasterDataset = null;
if (rasterBandCollection.Count > 1)
{
rasterBand = rasterBandCollection.Item(1);
rasterDataset = rasterBand.RasterDataset;
raster = rasterDataset.CreateDefaultRaster();
}
else
{
raster = null;
}
return raster;
}
[VB.NET]
Public Function GetSecondRaster(ByVal raster_ResultOfCurvature As IRaster) As IRaster
Dim raster As IRaster
' Gets the second band of a multiband raster.
Dim rasterBandCollection As IRasterBandCollection = CType(raster_ResultOfCurvature, IRasterBandCollection)
Dim rasterBand As IRasterBand
Dim rasterDataset As IRasterDataset
If rasterBandCollection.Count > 1 Then
rasterBand = rasterBandCollection.Item(1)
rasterDataset = rasterBand.RasterDataset
raster = rasterDataset.CreateDefaultRaster
Else
raster = Nothing
End If
Return raster
End Function
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Basic: Spatial Analyst | ArcGIS for Desktop Basic |
ArcGIS for Desktop Standard: Spatial Analyst | ArcGIS for Desktop Standard |
ArcGIS for Desktop Advanced: Spatial Analyst | ArcGIS for Desktop Advanced |