Generate Map Server Cache Tiling Scheme (Server)

Summary

Generates a custom tiling scheme file that defines the scale levels, tile dimensions, and other properties for a web tile layer.

A tiling scheme describes how clients should reference the tiles in a cache and is a mapping between the spatial reference of the source map document and the tiling grid. The tiling grid uses a level of detail (scales), row, and column reference scheme. The scheme also defines the scale levels (levels of detail) at which the cache has tiles, the size of the tiles in pixels, and the screen resolution for which the tiles are intended to be most commonly displayed. A tiling scheme is needed to generate a map cache.

Usage

  • By default, the tiling origin starts at the upper left of the coordinate system used by the service's source map document.

Parameters

LabelExplanationData Type
Map Document

The current map or an existing .mxd document to be used for the tiling scheme.

Map
Tiling origin in map units

The upper left corner of the tiling scheme, in coordinates of the spatial reference of the source data frame.

Point
Output Tiling Scheme

Path and file name of the tiling scheme file to create.

File
Number of Scales

Number of scale levels in the tiling scheme.

Long
Scales

Scale levels to include in the tiling scheme. These are not represented as fractions. Instead, use 500 to represent a scale of 1:500, and so on.

Value Table
Dots(Pixels) Per Inch

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 Size

The width and height of the cache tiles in pixels. The default is 256 by 256. For the best balance between performance and manageability, avoid deviating from standard dimensions of 256 by 256 or 512 by 512.

  • 128 by 128 pixels128 by 128 pixels
  • 256 by 256 pixels256 by 256 pixels
  • 512 by 512 pixels512 by 512 pixels
  • 1024 by 1024 pixels1024 by 1024 pixels
String

arcpy.server.GenerateMapServerCacheTilingScheme(in_map, tile_origin, output_tiling_scheme, num_of_scales, scales, dots_per_inch, tile_size)
NameExplanationData Type
in_map

The current map or an existing .mxd document to be used for the tiling scheme.

Map
tile_origin

The upper left corner of the tiling scheme, in coordinates of the spatial reference of the source data frame.

Point
output_tiling_scheme

Path and file name of the tiling scheme file to create.

File
num_of_scales

Number of scale levels in the tiling scheme.

Long
scales
[scales,...]

Scale levels to include in the tiling scheme. These are not represented as fractions. Instead, use 500 to represent a scale of 1:500, and so on.

Value Table
dots_per_inch

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_size

The width and height of the cache tiles in pixels. The default is 256 by 256. For the best balance between performance and manageability, avoid deviating from standard dimensions of 256 by 256 or 512 by 512.

  • 128 x 128128 by 128 pixels
  • 256 x 256256 by 256 pixels
  • 512 x 512512 by 512 pixels
  • 1024 x 10241024 by 1024 pixels
String

Code sample

GenerateMapServerCacheTilingScheme example

Creates a map cache tiling scheme with four scales.

# Name: GeneateMapServerCacheTilingScheme.py
# Description: The following stand-alone script demonstrates how to create map
#               server cache schema using a given map document at a given
#               "pathForOutputXml"
# Requirements: os, sys, time & traceback modules

# Any line that begins with a pound sign is a comment and will not be executed
# Empty quotes take the default value.
# To accept arguments from the command line replace values of variables to
#                                                           "sys.argv[]"

# Import system modules
import arcpy
from arcpy import env
import os, sys, time, datetime, traceback, string

# Set environment settings
env.workspace = "C:/data"

# List of input variables for map service properties
mapDocument = "C:/data/101/Portland/mxd/_M_Portland_classic_FGDB_Local.mxd"
dataFrame = ""
outputTilingScheme = "C:/data/port.xml"
tileOrigin = ""
numOfScales = "4"
scales = "500000,250000,125000,64000"
tileSize = "256 x 256"
dotsPerInch = "96"

currentTime = datetime.datetime.now()
arg1 = currentTime.strftime("%H-%M")
arg2 = currentTime.strftime("%Y-%m-%d %H:%M")
file = r'C:/data/report_%s.txt' % arg1

# print results of the script to a report
report = open(file,'w')

try:
    starttime = time.clock()
    result = arcpy.server.GenerateMapServerCacheTilingScheme(mapDocument, dataFrame,
                                                             tileOrigin, outputTilingScheme,
                                                             numOfScales, scales,
                                                             dotsPerInch, tileSize)
    finishtime = time.clock()
    elapsedtime = finishtime-starttime

    #print messages to a file
    while result.status < 4:
        time.sleep(0.2)
    resultValue = result.getMessages()
    report.write ("completed " + str(resultValue))

    print(" Created MapServer cache tiling schema successfully using" + \
        mapDocument + " at "+ outputTilingScheme + " in " + str(elapsedtime) + \
        " sec \n on " + arg2)

except Exception as e:
    # If an error occurred, print line number and error message
    tb = sys.exc_info()[2]
    report.write("Failed at step 1 \n" "Line %i" % tb.tb_lineno)
    report.write(str(e))

print("Created Map server Cache Tiling schema ")

report.close()

Environments

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics