Updates the scale levels in an existing map image layer in ArcGIS Enterprise or in a cached map or image service on a stand-alone server. Use this tool to add new scales or delete existing scales from a cache.
Usage
In ArcGIS Enterprise, the Input Service parameter is a string containing the REST endpoint of the service. Ensure that your ArcGIS Enterprise portal is the active portal.
In a stand-alone ArcGIS Server, the Input Service parameter is a string containing both the server and the service information. To construct the string, add the full path to the ArcGIS Server connection file (.ags) with Publisher or Administrator credentials to the service name on the stand-alone server, for example: "C:\path_to_the connection_file_of_standAloneServer\arcgis on MyServer.com_6443.ags\ServiceName.MapServer". For more information, see Connect to a GIS server.
If you remove scales from an existing cache, all existing cached tiles within that level of detail will be permanently deleted.
Caution:
You must specify existing scale values if you want to keep them. Any existing scale levels that are not specified will be permanently deleted. For example, if you have four existing scales and you want to add two scales, make sure that your list has a total of six scales.
The map image layer or map or image service where cache scales will be added or removed. You can drag a map or an image service from the Catalog tree to supply this parameter value.
Image Service; Map Server
Scales
The scale values that will be included in the updated tiling scheme.
The map image layer or map or image service where cache scales will be added or removed. In ArcGIS Enterprise, this is a string containing the REST endpoint of the web map image layer. In a stand-alone ArcGIS Server, this is a string containing both the server and the service information.
Image Service; Map Server
scales[scales,...]
The scale values that will be included in the updated tiling scheme.
Value Table
Derived output
Name
Explanation
Data type
out_job_url
The output URL.
String
Code sample
ManageMapServerCacheScales example (stand-alone script)
This example demonstrates how to add a new scale in a tiling scheme for a map or image service.
# Name: ManageMapServerCacheScales.py
# Description: The following stand-alone script demonstrates how to add a new
# scale in a tiling scheme for a map or image service.
# This tool only works for weblayers/services based on
# ArcGIS Enterprise or a stand alone ArcGIS Server
import arcpy
import os
# Sign in to portal
myPortal= "https://www.myArcGISEnterprise.com/webadaptor"
arcpy.SignInToPortal(myPortal, "MyUserName", "MyPassword")
serviceName= "MyCounty"
serviceType= "MapServer"
myPortalServiceURL = (myPortal + "/" + "rest/services" +"/" + serviceName + "/" + serviceType)
# Stand alone ArcGIS Server
target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"
serviceName= "MyCounty"
serviceType= "MapServer"
myServerServiceURL= target_server_connection + "/" + serviceName + "." + serviceType
desiredScales= "18055.954822;9027.977411;4513.988705;2256.994353;1128.497176;564.248588;282.124294;141.062147;70.5310735;35.2655"
# Variables for reporting
currentTime = datetime.datetime.now()
arg1 = currentTime.strftime("%H-%M")
arg2 = currentTime.strftime("%Y-%m-%d %H:%M")
file = 'C:/results/report_%s.txt' % arg1
# Print results of the script to a report
report = open(file,'w')
try:
result = arcpy.server.ManageMapServerCacheScales(myServerServiceURL, desiredScales)
while result.status < 4:
time.sleep(0.2)
resultValue = result.getMessages()
report.write ("completed " + str(resultValue))
except Exception as e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
report.write("Failed at step 1 \n" "Line %i" % tb.tb_lineno)
report.write(e.message)
report.close()
print ("Updated Cache Tiling Scales for " + serviceName)
Environments
This tool does not use any geoprocessing environments.