Summary
Generates a cache of static image tiles for an ArcGIS Server map service.
Usage
This tool only works with ArcGIS Server map services.
Before running this tool, configure the map service to use as many instances as possible. This will dramatically decrease cache generation time.
Only one data frame can be cached at a time. If other data frames are needed, separate caches must be generated that associated with separate map services.
The tiling scheme determines how the client should reference the tiles in the cache. A new tiling scheme can be created, or an existing tiling scheme created with the Generate Map Server Cache Tiling Scheme tool can be used.
Use Fused caches for most cases. All the layers in the map are composited into single images for each specified scale level, then split into many tiles.
Use Multi-layer caches for cases where you want to toggle layers on and off.
The Number of Scales parameter is the number of different map scales the tool will create layers for in the cache.
Computing large map scale levels for very large map extents (such as a large state, province, or country) can result in large creation times. For example, computing a tile size for map scales larger than 1:100,000 for all of North America.
The primary benefit of employing image-compression in your cache is to reduce the size of the image tiles to improve performance over the network. Because less data is transmitted between the client and the server, it is possible to cache large, seamless raster datasets (as large as several terabytes) and serve them quickly to a client for display. An added benefit is the significantly reduced size of the cache on disk.
When using this tool to add additional levels (scales) to an existing cache, make sure to specify the same compression factor that was used in the original levels.
JPEG is best used with raster data. When used with vector data, lines and text may be blurred.
JPEG file format is not supported for multi-layer caches.
The cache tile format cannot be changed once the cache is generated. The cache must first be deleted before switching to a different file format.
For best performance of streaming cache tiles to clients choose the JPEG image format. For the best combination of performance and transparency support, choose the PNG8 image format.
The Antialiasing option smooths out the edges of lines and text, but offers little enhancement for raster images.
This tool does not accept any Environment Settings that have been specified.
Syntax
GenerateMapServerCache_server (server_name, object_name, data_frame, out_folder, tiling_scheme_type, scales_type, num_of_scales, dpi, tile_width, tile_height, {map_or_layers}, {tiling_schema}, {tile_origin}, {levels}, {layer}, {thread_count}, {Antialiasing}, {cache_format}, {tile_compression_quality})
Parameter | Explanation | Data Type |
server_name | The host name of the ArcGIS Server to use to generate the cache. | String |
object_name | The name of the map service to use to generate the cache. | String |
data_frame | The map documents data frame to cache. Make sure you select the same data frame that you selected for your map service. | String |
out_folder | The parent directory for this map service cache. | String |
tiling_scheme_type | Choose to use a NEW or PREDEFINED tiling scheme. A new tiling scheme can be defined in this tool, or a predefined scheme file (.xml) can be loaded. A predefined scheme can be created by running the Generate Map Server Cache Tiling Scheme GP Tool. NEW is the default. | Boolean |
scales_type | Set the scale level
| Boolean |
num_of_scales | The number of scale levels to create in the cache. | Long |
dpi | The dots per inch of the intended output device. If a DPI is chosen that does not match the resolution of the output device, the scale of the map tile will appear incorrect. The default value is 96. | Long |
tile_width | The width, in pixels, of output map tiles. Small widths map improve performance of the application requesting tiles from the cache as less data will travel over the wire. However, smaller tile size results in a larger cache size and longer creation time. The default tile width is 512. | Long |
tile_height | The height, in pixels, of output map tiles. Small heights map improve performance of the application requesting tiles from the cache as less data will travel over the wire. However, smaller tile size results in a larger cache size and longer creation time. The default tile height is 512. | Long |
map_or_layers (Optional) | Choose to generate a FUSED or MULTI_LAYER cache:
| Boolean |
tiling_schema (Optional) | Path to a pre-defined tiling scheme. | String |
tile_origin (Optional) | Specify the origin (upper left corner) of the tiling scheme in coordinates of the spatial reference of the source map document. The extent of the source map document must be within (but does not need to coincide) with this region. | String |
levels Scale; Scale... (Optional) | Scales at which to cache the map service. | String |
layer Layer; Layer... (Optional) | Layers to include in the cache if MULTI_LAYER cache type is chosen. | String |
thread_count (Optional) | The number of MapServer instances to use while generating the cache. | Long |
Antialiasing (Optional) | Choose whether to use antialiasing when rendering the tiles. If ANTIALIASING is chosen, edges of lines, borders, and text will be smoothed. There is a performance cost for this option. No benefit will be gained on raster data. | Boolean |
cache_format (Optional) | Choose either PNG8, PNG24, PNG32 or JPEG file format for the tiles in the cache. PNG24 is the default.
| String |
tile_compression_quality (Optional) | Enter a value between 1 and 100 for the JPEG compression quality. The default value is 75 for JPEG tile format and zero for other formats. Compression is supported only for JPEG format. The level of compression will depend on the data, but can also be controlled by changing the compression quality. Choosing a higher value will result in less compression and a higher-quality image. Choosing a lower value will result in more compression but a lower-quality image. | Long |
Code Sample
# Script Name: Generate Fused Map Server Cache
# Description: Generates a fused map server cache using PNG8 image format
# Uncomment sys.argv[] lines to accept arguments from the command line.
# Import standard library modules
import sys, string, os, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create()
# Set the path to the cache.
# Example: \\\\myServer\\arcgiscache\\MyServiceFolder_MyService\\
out_folder = "\\\\myServer\\arcgiscache\\MyServiceFolder_MyService\\"
#out_folder = sys.argv[1]
# Set the SOM server name
# Example: "mySOM"
server_name = "mySOM"
#server_name = sys.argv[2]
# Set the object_name
# Example: "MyServiceFolder/MyService"
object_name = "MyServiceFolder/MyService"
#object_name = sys.argv[3]
# Set the data frame
# Example: "Layers"
data_frame = "Layers"
#data_frame = sys.argv[4]
# Set the map cache tiling origin
# Example: "-180 90"
tile_origin = "-180 90"
#tile_origin = sys.argv[5]
# Set the scale levels for the cache.
# Example: "2000000;500000;250000"
scales = "2000000;500000;250000"
#scales = sys.argv[6]
# Set the layers to cache.
# Example: "My First Layer;My Second Layer;My Third Layer"
layers = "My First Layer;My Second Layer;My Third Layer"
#layers = sys.argv[7]
# Set number of instances to use while updating the cache
# Example: "3"
thread_count = "3"
#thread_count = sys.argv[8]
# Set cache tile image format.
# Example: "PNG8"
cache_format = "PNG8"
#layers = sys.argv[9]
# Non-argument variable declarations
tiling_scheme_type = "NEW"
tiling_schema = ""
scales_type = "STANDARD"
num_of_scales = "3"
dpi = "96"
tile_width = "512"
tile_height = "512"
map_or_layers = "FUSED"
antialiasing = "ANTIALIASING"
tile_compression_quality = "0"
try:
print 'Starting Cache Generation'
gp.GenerateMapServerCache(server_name, object_name, data_frame, out_folder, tiling_scheme_type, scales_type, num_of_scales, dpi, tile_width, tile_height, map_or_layers, tiling_schema, tile_origin, scales, layers, thread_count, antialiasing, cache_format, tile_compression_quality)
print 'Finished Cache Generation'
except:
gp.AddMessage(gp.GetMessages(2))
print gp.GetMessages(2)
Environments
This tool does not use any geoprocessing environments
Licensing Information
- ArcGIS for Desktop Basic: Yes
- ArcGIS for Desktop Standard: Yes
- ArcGIS for Desktop Advanced: Yes