Tutorial: Creating a cached image service
The best way to create fast image services is to cache them. When you cache an image service, the server draws the image at a set of scale levels and pixel sizes that you define and saves the preprocessed (cached) images. So, when the server receives a request for an image, it's much quicker to return one of these cached images than to draw the original image again.
Caching is appropriate for image services that don't change often. If they do change, there are tools available to update the cache.
Creating an effective image service cache requires you to do some design and authoring work before you build the cache. You can create an image service from a mosaic dataset, raster dataset or a layer file referencing a raster dataset or mosaic dataset. This tutorial walks you through the process of planning and authoring an image service that will be cached using the ArcGIS Online/Bing Maps/Google Maps tiling scheme. You'll then create an image service and cache it. Finally, you'll test the cache in a client application.
If the source of your image service is a mosaic dataset, it is important that you use WGS 1984 Web Mercator (Auxiliary Sphere) as its coordinate system, which is the same coordinate system used by ArcGIS Online, Google Maps, and Bing Maps.
When working on this tutorial, select some simple datasets that cover a fairly small area, such as a city or county. This tutorial is meant as a practice so that you can prepare for future caching jobs within your organization. Pay close attention to the discussion and instructions, but don't worry about getting it perfect the first time. Designing good caches takes some practice.
This tutorial has three main sections:
- Authoring an image service
- Publishing an image service (and generating the cache)
- Testing the cache
Before beginning this tutorial
If you've just installed ArcGIS for Server, you need to complete some preparatory steps before you can connect to ArcGIS for Server in ArcMap and publish services:
- For details on how to configure your ArcGIS Server site, see the Getting started after install section of this help system.
- To serve an image service from a mosaic dataset or mosaic dataset layer, you need the ArcGIS Image extension , whereas a raster dataset or raster dataset layer can be served without this extension.
- To learn how to make the data in the image service available to the server, see Making your data accessible to ArcGIS for Server.
Authoring an image service
When you cache an image service, the server draws it at a set of scales or pixel sizes that you select. Once an image service is cached, you can't change the way it looks unless you re-create or update the cache. This means two important things:
An image service needs to look good and display the correct raster at each scale level before you cache it.
A cached image service has to be designed for every scale that you cache. Each image service has its own set of properties such as mosaic method based on which the rasters are selected for mosaicking and to be displayed for each scale level.
The scale levels and pixel sizes you choose are very important.
If you pick too few scales, users may feel that they are missing information or cannot get a good view of the image service. If you pick too many scales or pick scales that are unnecessary, you increase the cache creation time and required storage space. Conversely, your organization may have already determined a tiling scheme to use when caching. A tiling scheme determines certain properties of your cache, including which scale levels and pixel sizes to create.
When a mosaic dataset is used as the source of your image service, it is better to note the number of levels that your mosaic dataset has so that you select the appropriate scale levels or pixel sizes when defining the tiling scheme. The number of levels can be identified by looking at the cell size level table of a mosaic dataset.
In this tutorial, it is assumed that your organization uses the ArcGIS Online/Bing Maps/Google Maps tiling schemes. To get started, follow the steps below.
Designing an image service
One benefit of caching your image service is that during the design phase of its source dataset, you can apply different raster functions without worrying about how they will affect the performance. Take some time to remember everything you need to do on your image service, because once the cache is created, you will not be able to make any changes without re-creating or updating the cache.
If you know you will be creating a mosaic dataset that will be published as an image service and cached using the ArcGIS Online/Bing Maps/Google Maps tiling schema, create the mosaic dataset using the WGS 1984 Web Mercator (Auxiliary Sphere) or the WGS 1984 Web Mercator coordinate system.
If you create a mosaic dataset in a different projection then the one you need to use for caching, you should create a referenced mosaic dataset from the mosaic dataset in the projection you need. This is because you can't change the projection of a mosaic dataset.
See Preparing image services for more information on designing the source dataset of an image service.
Publishing an image service
This phase of the tutorial walks you through the process of publishing your image service to ArcGIS for Server using ArcMap. During this process, you will define the schema of your image service cache and analyze your image service. Once you accomplish these tasks, you'll publish your image service.
- Start ArcMap.
- In the Catalog window, right-click the dataset or layer and click Share As Image Service.
- Choose Publish as service and click Next.
- Click the Choose a connection drop-down list and select the server.
- Optionally, enter a new name for the service.
The name cannot be more than 120 characters long and may contain only alphanumeric characters and underscores.
- Click Next.
- By default, services are published to the root directory [root] of ArcGIS for Server. Alternatively, services can be organized in folders within the root directory. Choose the folder where you want to publish the service, or create a new folder to contain the service.
- Click Continue.
The Service Editor displays. You'll use the Service Editor to choose what users can do with your image service and take fine-grained control of how the server will expose your image service.
For information on specific parameters and capabilities, see Image services and their capabilities.
- In the left pane of the Service Editor, click Capabilities.
By default, Imaging is enabled.
- In the left pane under Capabilities, click Imaging and review the information.
URL—These are the URLs clients use to access the image service. The SOAP URL will be formatted as follows: http://gisserver.domain.com:6080/arcgis/services/folder/service/ImageServer. The REST URL will be formatted as follows: http://gisserver.domain.com:6080/arcgis/rest/services/folder/service/ImageServer.
Operations allowed—There are several operations available when using the image service. Each of these options can limit what clients can do with your service. For more information, see Image services and their capabilities.
- In the left pane of the Service Editor dialog box, click Caching.
- Choose Using tiles from a cache to draw this service.
- Click the Tiling Scheme drop-down arrow and click ArcGIS Online / Bing Maps / Google Maps.
This specifies that your cached image service will use the ArcGIS Online/Bing Maps/Google Maps cache tile schema and scale levels.Note:
If you select Suggest from the Tiling Scheme drop-down list, you will be asked how many levels to use to generate a default tiling scheme. You can change this by clicking Advanced Settings in the left pane.
- Examine the Estimated Cache Size. Then decrease (move left) the Maximum scale level slider on the Levels of Detail bar until the Estimated Cache Size is below 50 MB. This ensures an appropriate testing cache size.
As you move the slider, you will notice the Level, Scale, and Cell Size values change to represent the information of the highest cache level. When using a mosaic dataset, you could choose to generate a cache only where the overviews have not been generated.
- For the purposes of this tutorial, leave all other default settings. Notice that one of the defaults you are accepting is to build the cache automatically when the service is published. For larger caches, you might want to build the cache manually at a different time (such as overnight or during the weekend).
- In the left pane, click Advanced Settings, click the Tile Format drop-down arrow, then click JPEG.
The JPEG format produces small tiles and will reduce the disk space needed to store the cache. Clients can also load the tiles quicker.
Alternatively, you could choose MIXED. The mixed cache uses JPEG when the cache tile is completely covered by the image and PNG32 for the tiles that contain areas that should be displayed transparently.
- Click the Advanced button.
- Click the Storage Format drop-down arrow and click Compact.
This format groups cache tiles into large files rather than storing the tiles as individual files.
- Click OK to close the dialog box.
- Click the Cache Directory drop-down arrow to choose the directory where you want your cache to be created. If the list is blank, you need to add a server cache directory before you can continue. See Creating a server directory for full instructions.
- For the purposes of this tutorial, accept the remaining service setting defaults and continue.
- In the Service Editor, click Analyze.
This examines your dataset to see if it can be published to the server. Results are displayed in the Prepare window. You must fix the Errors before you can publish the image service. For more information about resolving these issues, see the topic Analyzing your GIS resource.Tip:
To give yourself more viewing area, click the Collapse button at the top of the Service Editor.
- Optionally, in the Service Editor, click Preview.
This can give you an idea of how your data will look when viewed on the web. See Previewing your map for more information.
- Once you've fixed any errors, click Publish.
The image service immediately begins publishing. After publishing is complete, the server starts to build cache tiles and will continue until the cache is built.
Depending on your largest scale, the hardware comprising your server, the extent of your data, and other factors, the cache can take some time to generate. If you picked a simple raster dataset or mosaic dataset with a small geographic extent for this exercise, the cache will probably be completed in several minutes. The geoprocessing status window shows a progress bar of how much of your cache has been completed.
Testing the cache
Once the cache is finished, you can test it in a web application to make sure that the image service appears and performs the way you expect. This is also a good way to verify that the tiles are being recognized and used successfully by the application.
- In a web browser, navigate to the Services Directory. For example, http://gisserver.domain.com:6080/arcgis/rest/services.
- In the services list, click your image service. All image services are appended with (ImageServer). If your service resides in a folder, navigate to that folder and select the service.
- Pan around the image service and zoom to the different levels. When panning and zooming in the image service, you should see the image tiles appear very quickly.
If it doesn't appear that the application is using the cache, make sure that:
- Your service pack levels match (if you have service packs applied).
- The ArcGIS Server account has read and write permissions to your server cache directory.
If you're using Mozilla Firefox to view your web application, there's an easy way to tell if your cache tiles are being used.
- Right-click inside the web application and choose View Page Info.
- In the Page Info window, click the Media button.
- Examine the images that appear in the list. If you see URLs referencing your server cache directory, you know your cache is being used.