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


How to create a local 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 create a local image service (ArcObjects .NET 10.6 SDK)

How to create a local image service


Creating a local image service

The following code example shows how to create a local image server object from a mosaic dataset, and set configurations:
[C#]
public static IImageServer InitializeImageServer(string mosaicDatasetPath)
{
    //Initialize.
    IImageServerInit2 isInit2=new ImageServerClass();
    isInit2.Initialize(mosaicDatasetPath);

    //Set configuration parameters (default compression: JPEG; default mosaic method: MosaicToCenter).  
    isInit2.AllowedCompressions="JPEG,None,LZ77";
    isInit2.AllowedFields="MinPS,MaxPS,LowPS,HighPS,CenterX,CenterY";
    isInit2.AllowedItemMetadata="Full";
    isInit2.AllowedMosaicMethods="Center,NorthWest,ByAttribute,LockRaster";
    isInit2.ExcludedFields="Raster";
    isInit2.MaxImageHeight=4100;
    isInit2.MaxImageWidth=15000;
    isInit2.MaxRecordCount=20;

    //Cast to IImageServer.
    IImageServer imageServer=isInit2 as IImageServer;
    return imageServer;
}
[VB.NET]
Public Shared Function InitializeImageServer(ByVal mosaicDatasetPath As String) As IImageServer
'Initialize.
Dim isInit2 As IImageServerInit2=New ImageServerClass()
isInit2.Initialize(mosaicDatasetPath)

'Set configuration parameters (default compression: JPEG; default mosaic method: MosaicToCenter).
isInit2.AllowedCompressions="JPEG,None,LZ77"
isInit2.AllowedFields="MinPS,MaxPS,LowPS,HighPS,CenterX,CenterY"
isInit2.AllowedItemMetadata="Full"
isInit2.AllowedMosaicMethods="Center,NorthWest,ByAttribute,LockRaster"
isInit2.ExcludedFields="Raster"
isInit2.MaxImageHeight=4100
isInit2.MaxImageWidth=15000
isInit2.MaxRecordCount=20

'Cast to IImageServer.
Dim imageServer As IImageServer=CType(isInit2, IImageServer)
Return imageServer
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 Standard
ArcGIS Desktop Standard ArcGIS Desktop Advanced
ArcGIS Desktop Basic ArcGIS Desktop Basic
Engine Developer Kit Engine