arcpy.server.GenerateMapServerCacheTilingScheme(in_map, tile_origin, output_tiling_scheme, num_of_scales, scales, dots_per_inch, tile_size, {ready_to_serve_format}, {output_folder})
|
Name
|
Explanation
|
Data type
|
|
in_map
|
The current map or an existing .mxd file to be used for the tiling scheme.
|
Map
|
|
tile_origin
|
The origin (upper left corner) of the tiling scheme in the coordinates of the spatial reference of the source data frame.
|
Point
|
|
output_tiling_scheme
|
The path and file name of the tiling scheme file that will be created.
|
File
|
|
num_of_scales
|
The number of scale levels that will be included in the tiling scheme.
|
Long
|
|
scales
[scales,...]
|
The scale levels that will be included in the tiling scheme. These are not represented as fractions. Instead, use 500 to represent a scale of 1:500, and so on, for example.
|
Value Table
|
|
dots_per_inch
|
The dots per inch (DPI) of the intended output device. If a DPI is specified 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
|
Specifies the width and height of the cache tiles in pixels. For the best balance between performance and manageability, avoid deviating from standard dimensions of 256 by 256 or 512 by 512.
128 x 128—The width and height of the cache tiles will be 128 by 128 pixels.
256 x 256—The width and height of the cache tiles will be 256 by 256 pixels. This is the default.
512 x 512—The width and height of the cache tiles will be 512 by 512 pixels.
1024 x 1024—The width and height of the cache tiles will be 1024 by 1024 pixels.
|
String
|
|
ready_to_serve_format
(Optional)
|
Specifies the file format of the cache schema that will be used and whether it will be generated using the open tile package specification.
READY_TO_SERVE_FORMAT—The cache schema will be generated in JSON format using the open tile package specification. An output folder must be specified in the output_folder parameter.
NON_READY_TO_SERVE_FORMAT—The cache schema will be generated in XML format. This is the default.
|
Boolean
|
|
output_folder
(Optional)
|
The folder location where the cache schema and iteminfo files will be created in JSON format.
|
Folder
|
Code sample
GenerateMapServerCacheTilingScheme example 1 (XML format)
The following example creates a map cache tiling scheme in XML format.
# 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 run
# 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 sys
import time
# Set environment settings
env.workspace = "E:/path/to/myfolder"
# List of input variables for map service properties
# Reference map to use for cache tiling sceheme generation
aprx = arcpy.mp.ArcGISProject(r"E:\Data\path\to\myAPRX.aprx")
mapDocument = aprx.listMaps("myMapName")[0]
outputTilingScheme = "E:/path/to/myschema.xml"
tileOrigin = ""
numOfScales = "4"
scales = "4000000,2000000,100000,50000"
tileSize = "256 x 256"
dotsPerInch = "96"
# print results of the script to a report
file = r'E:\path\to\myreport.txt'
report = open(file,'w')
try:
#starttime = time.clock()
result = arcpy.server.GenerateMapServerCacheTilingScheme(mapDocument,
tileOrigin, outputTilingScheme,
numOfScales, scales,
dotsPerInch, tileSize)
#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 )
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()
GenerateMapServerCacheTilingScheme example 2 (JSON format)
The following example creates a map cache tiling scheme in JSON format.
# Name: GeneateMapServerCacheTilingScheme.py
# Description: The following stand-alone script demonstrates how to create map
# server cache schema in ready to serve format using a given map document at a given
# folder
# Requirements: os, sys, time & traceback modules
# Any line that begins with a pound sign is a comment and will not be run
# 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 sys
import time
# Set environment settings
env.workspace = "E:/path/to/myfolder"
# List of input variables for map service properties
# Reference map to use for cache tiling sceheme generation
aprx = arcpy.mp.ArcGISProject(r"E:\Data\path\to\myAPRX.aprx")
mapDocument = aprx.listMaps("myMapName")[0]
outputTilingScheme = "None"
tileOrigin = ""
numOfScales = "4"
scales = "4000000,2000000,100000,50000"
tileSize = "256 x 256"
dotsPerInch = "96"
ready_to_serve_format = "READY_TO_SERVE_FORMAT"
output_folder = "E:\\path\\to\\myfolder"
# print results of the script to a report
file = r'E:\path\to\myreport.txt'
report = open(file,'w')
try:
#starttime = time.clock()
result = arcpy.server.GenerateMapServerCacheTilingScheme(mapDocument,
tileOrigin, outputTilingScheme,
numOfScales, scales,
dotsPerInch, tileSize,
ready_to_serve_format,
output_folder)
#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 )
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()