How to set a mosaic rule and export a map image from an image service (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with image and raster data > Working with image services and WCS services > How to set a mosaic rule and export a map image from an image service (ArcObjects .NET 10.6 SDK)

How to set a mosaic rule and export a map image from an image service


Summary
When accessing an image service published from a mosaic dataset that represents a virtual mosaic of multiple images, the virtual mosaic uses a default mosaic rule. This topic shows how to set a mosaic rule and export a map image from an image service.

Setting a mosaic rule and exporting a map image from an image service

A client can specify a mosaic rule when sending GetImage, ExportImage, or ExportMapImage requests to the server. The service mosaics the image with the mosaic rule and returns an image. The following code example shows how to user lock a raster and export a map image:
[C#]
public static string ExportMapImage_LockRaster(IImageServer imageServer)
{
    //Cast.
    IImageServer2 imageServer2=(IImageServer2)imageServer;
    //Define the mosaic rule (center).
    IMosaicRule mosaicRule=new MosaicRuleClass();
    mosaicRule.MosaicMethod=esriMosaicMethod.esriMosaicLockRaster;
    mosaicRule.LockRasterID="1,2,3";
    mosaicRule.MosaicOperatorType=rstMosaicOperatorType.MT_MAX;

    //Define the image description with a mosaic rule.
    IGeoImageDescription2 geoImageDesc=new GeoImageDescriptionClass();
    geoImageDesc.Height=600;
    geoImageDesc.Width=800;
    geoImageDesc.Compression="JPEG";
    geoImageDesc.Interpolation=rstResamplingTypes.RSP_BilinearInterpolation;
    geoImageDesc.Extent=imageServer.ServiceInfo.Extent;
    geoImageDesc.MosaicRule=mosaicRule;

    //Define the image return format and the type.
    IImageType imgType=new ImageTypeClass();
    imgType.Format=esriImageFormat.esriImageJPG;
    imgType.ReturnType=esriImageReturnType.esriImageReturnURL;

    //Process the export map image request.
    IMapImage mapImage=imageServer2.ExportMapImage(geoImageDesc, imgType);
    return mapImage.URL;
}
[VB.NET]
Public Shared Function ExportMapImage_LockRaster(ByVal imageServer As IImageServer) As String
'Cast.
Dim imageServer2 As IImageServer2
imageServer2=CType(imageServer, IImageServer2)
'Define the mosaic rule (center).
Dim mosaicRule As IMosaicRule=New MosaicRuleClass()
mosaicRule.MosaicMethod=esriMosaicMethod.esriMosaicLockRaster
mosaicRule.LockRasterID="1,2,3"
mosaicRule.MosaicOperatorType=rstMosaicOperatorType.MT_MAX

'Define the image description with a mosaic rule.
Dim geoImageDesc As IGeoImageDescription2=New GeoImageDescriptionClass()
geoImageDesc.Height=600
geoImageDesc.Width=800
geoImageDesc.Compression="JPEG"
geoImageDesc.Interpolation=rstResamplingTypes.RSP_BilinearInterpolation
geoImageDesc.Extent=imageServer.ServiceInfo.Extent
geoImageDesc.MosaicRule=mosaicRule

'Define the image return format and the type.
Dim imgType As IImageType=New ImageTypeClass()
imgType.Format=esriImageFormat.esriImageJPG
imgType.ReturnType=esriImageReturnType.esriImageReturnURL

'Process the export map image request.
Dim mapImage As IMapImage
mapImage=imageServer2.ExportMapImage(geoImageDesc, imgType)
Return mapImage.URL
End Function






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