ArcGIS Image Service Layer

An ArcGIS Image Service layer displays imagery and other types of raster data provided by an ArcGIS Server Image Service.

ArcGIS Image Service Layer is a dynamic layer. It requests new map images when a user navigates the map. Because the map images are created dynamically when the layer requests them, contents of map images can be customized by modifying some layer properties. If the layer's spatial reference does not match the map's spatial reference, the layer will automatically re-project its map contents to match the map's spatial reference.

About Image Services

Image Services are based on raster data. Raster data is essentially a grid of cells. Each cell corresponds to a physical location and the cell's value represents information about that location. Raster format is usually preferred over vector format to store continuous data such as rainfall or elevation because it can better represent granular variations in data over an area. Rasters are also commonly used to store imagery and other information captured by satellite sensors.

Learn more about raster data.

Learn more about Image Services

The data for an Image Service can be in any of the supported raster formats. The data can be published to an ArcGIS Server to create an Image Service. Depending upon how the data is stored, some Image Service functionality may not be available. For example, the ability to specify mosaic rules is only available if the data is stored as a mosaic dataset. For more information about which capabilities are available for different inputs, refer to the Image Service Parameters topic.

Image Services are accessible on the web as SOAP and REST web services. You can find the URL of these web services on the ArcGIS Services Directory.

Creating the layer

To create an Image Service layer, you need to instantiate an object of the AGSImageServiceLayer class. When instantiating the object, you need to provide a URL to the Image Service's REST web service endpoint. This URL is usually of the form http://<server:port>/<instance>/rest/services/<service>/ImageServer

NSURL* url = [NSURL URLWithString: @"http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Portland/CascadeLandsat/ImageServer"];
AGSImageServiceLayer* layer = [AGSDynamicMapServiceLayer imageServiceLayerWithURL: url];

After creating the layer, you can add it to a map to display its contents.

Modifying map contents

An Image Service layer allows you modify map contents displayed by the layer by specifying a few properties. For example, you can specify the amount of compression (0% - 100%) that should be applied to reduce the size of the map image. This is especially useful for accessing high resolution imagery over low bandwidth connections.

Band Combinations

Raster data can have one or more bands of information. For example, elevation models usually contain a single band of elevation information and Panchromatic images contain a single band of grayscale values. Aerial photographs, on the other hand, usually contain 3 bands, one each for Red, Green, and Blue wavelengths. Some raster data can be multi-spectral, containing more than 3 bands of information from even beyond the visible light range, such as Infrared.

Learn about Raster Bands

An Image Service layer provides information about how many bands are available in the Image Service as follows :

AGSImageServiceInfo* imageInfo = layer.imageServiceInfo;
int bandCount = imageInfo.bandCount;
If bandCount is n, then each band is assigned a corresponding ID from 0 to n-1.

You can specify the combination of bands that should be included in the map images as follows :

//For a grayscale map image with band 0
NSArray* grayscaleBandIds = [NSArray arrayWithObject:[NSNumber numberWithInt:0] ];
layer.bandIds = grayscaleBandIds;

//Or, For a color image with band 2, band 5, and band 0 as Red, Green, and Blue respectively
NSArray* rgbBandIds = [NSArray arrayWithObjects:[NSNumber numberWithInt:2], [NSNumber numberWithInt:5], [NSNumber numberWithInt:0], nil ];
layer.bandIds = rgbBandIds;
NoteNote:

Even when the Image Service contains more than 3 bands, you can only specify either 1 band (for grayscale) or 3 bands (for color) to be included in the map image.

Mosaic Rules

Image Services based on mosaic datasets may contain many overlapping rasters. A mosaic rule defines the order in which rasters are combined together to create a map image. The following methods are supported :

  • Closest to Center. Rasters that have their center closest to the view center are placed on top.
  • Closest to Nadir. Orders rasters based on the distance between the nadir position and view center. This is similar to the Closest to Center method but uses the nadir point of a raster, which may be different than the center, especially for oblique imagery.
  • Closest to Viewpoint. Orders rasters based on th distance between a user-defined location and nadir location for the rasters.
  • By Attribute. Orders rasters based on the difference between a specified metadata attribute and a base value.
  • North-West. Rasters with their centers to the northwest are displayed on top.
  • Seamline. Cuts the raster using the predefined seamline shape for each raster using optional feathering along the seams and orders images based on the SOrder field in the attribute table.
  • Lock Raster. Enables a user to lock the display of a single or multiple rasters based on the ObjectID.
  • None. Orders rasters based on the order (ObjectID) in the mosaic dataset attribute table.

When specifying a mosaic rule, you must also specify a mosaic operation to determine what values should be assigned to pixels that are common to overlapping rasters.

Learn more about Mosaic operators

Here is an example of a mosaic rule being applied to an image service layer :

AGSMosaicRule* rule = [[[AGSMosaicRule alloc] init] autorelease];
rule.method = AGSMosaicMethodNadir;
rule.operation = AGSMosaicOperationTypeFirst;

layer.mosaicRule = rule;

Rendering Rules

Rendering rules allows you to perform complex processing, such as computing hillshade or slope, on raster data of an Image Service. The source data is not changed. Instead, processing is performed on-the-fly while generating map images. A rendering rule specifies the processing to be applied via a raster function.

Learn about raster functions

Image Service web services only support a subset of all available raster functions. The REST API documentation lists the supported raster functions, their JSON syntax, and any arguments they require.

The following code snippet shows how to apply a ShadedRelief raster function:

/* JSON syntax of ShadedRelief
{
  "rasterFunction" : "ShadedRelief",
  "rasterFunctionArguments" : {
    "Azimuth" : 215.0,
    "Altitude" : 75.0,
    "ZFactor" : 0.3,
    "Colormap" : [
      [0, 1, 2, 3],
      [2, 45, 52, 13]
    ]
  },
  "variableName" : "Raster"
}
*/

//arguments
NSMutableDictionary* arguments = [[[NSMutableDictionary alloc] init] autorelease];
[arguments setObject:[NSNumber numberWithDouble:215.0] forKey:@"Azimuth"];
[arguments setObject:[NSNumber numberWithDouble:75.0] forKey:@"Altitude"];
[arguments setObject:[NSNumber numberWithDouble:0.3] forKey:@"ZFactor"];

NSMutableArray* colorMap = [[[NSMutableArray alloc] init] autorelease];
NSArray* row1 = [NSArray arrayWithObjects:[NSNumber numberWithInt:0], [NSNumber numberWithInt:1], [NSNumber numberWithInt:2], [NSNumber numberWithInt:3], nil];
NSArray* row2 = [NSArray arrayWithObjects:[NSNumber numberWithInt:2], [NSNumber numberWithInt:45], [NSNumber numberWithInt:52], [NSNumber numberWithInt:13], nil];
[colorMap addObject:row1];
[colorMap addObject:row2];

[arguments setObject:colorMap forKey:@"Colormap"];

//raster function
AGSRasterFunction* rasterFunction = [[[AGSRasterFunction alloc] init] autorelease];
rasterFunction.type = AGSRasterFunctionTypeShadedRelief;
rasterFunction.arguments = arguments;

layer.renderingRule = rasterFunction;

Interpolation

An Image Service can generate map images of varying dimensions. This is important because the size of a map image suitable for a mobile device would be quite different from that of a map image for a desktop computer. However, Image Services use the same raster data to produce these map images. Interpolation techniques specify how to approximate pixel values for map images based on pixel values of the raster data. In simpler terms, interpolation is the process by which an image is resized or resampled.

The following resampling methods are supported :

  • Nearest Neighbor. The value of the pixel closest to the interpolated pixel is used.
  • Bilinear. A 2x2 pixel grid closest to the interpolated pixel is used. The value is the weighted average of values in the pixel grid.
  • Cubic Convolution. Similar to Bilinear interpolation except a 4x4 pixel grid is used.
  • Majority. The most frequent pixel value around the interpolated pixel is used.

Learn more about resampling

5/9/2012