Tutorial: Creating a cached image service

Complexity: Intermediate Data Requirement: Use your own data

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.

NoteNote:

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:

  1. Authoring an image service
  2. Publishing an image service (and generating the cache)
  3. 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:

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:

NoteNote:

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.

Steps:
  1. Start ArcMap.
  2. In the Catalog window, right-click the dataset or layer and click Share As Image Service.
  3. Choose Publish as service and click Next.
  4. Click the Choose a connection drop-down list and select the server.
  5. 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.

  6. Click Next.
  7. 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.
  8. 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.

  9. In the left pane of the Service Editor, click Capabilities.

    By default, Imaging is enabled.

  10. 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.

  11. In the left pane of the Service Editor dialog box, click Caching.
  12. Choose Using tiles from a cache to draw this service.
  13. 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.

    NoteNote:

    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.

    Learn about the tiling schemes

  14. 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.

  15. 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).
  16. 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.

    Learn about the tile formats

  17. Click the Advanced button.
  18. 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.

  19. Click OK to close the dialog box.
  20. 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.
  21. For the purposes of this tutorial, accept the remaining service setting defaults and continue.
  22. In the Service Editor, click Analyze 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 Error before you can publish the image service. For more information about resolving these issues, see the topic Analyzing your GIS resource.

    TipTip:

    To give yourself more viewing area, click the Collapse button Collapse at the top of the Service Editor.

  23. Optionally, in the Service Editor, click Preview 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.

  24. Once you've fixed any errors, click Publish 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.

The web application you use for testing can be a simple one. A good way to test your image service cache is to use the ArcGIS API for JavaScript viewer application available through ArcGIS Server Services Directory.

Steps:
  1. In a web browser, navigate to the Services Directory. For example, http://gisserver.domain.com:6080/arcgis/rest/services.
  2. 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.
  3. A page displays showing the name of your service, service description, and a list of layers. Click View In: ArcGIS JavaScript.
  4. A window with a simple JavaScript web application appears. The levels in the zoom-level slider correspond to the scales in your cache.
  5. 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.

Troubleshooting

If it doesn't appear that the application is using the cache, make sure that:

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.

Steps:
  1. Right-click inside the web application and choose View Page Info.
  2. In the Page Info window, click the Media button.
  3. Examine the images that appear in the list. If you see URLs referencing your server cache directory, you know your cache is being used.

Related Topics

4/10/2014