ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Manage Map Server Cache Scales

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

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.

Syntax

arcpy.server.ManageMapServerCacheScales(input_service, scales)
ParameterExplanationData Type
input_service

The map image layer or map or image service where cache scales will be added or removed.This is a string containing both the server and service information. To see how to construct this string, open ArcCatalog, select the service in the Catalog tree, and note the text on the Location toolbar. Then change the backslashes to forward slashes, for example, GIS Servers/arcgis on MYSERVER (admin)/USA.MapServer.

Image Service; Map Server
scales
[scales,...]

The scale values that will be included in the updated tiling scheme.

Value Table

Derived Output

NameExplanationData Type
out_job_url

The output URL.

String

Code sample

ManageMapServerCacheScales example (stand-alone script)

This example modifies a map cache tiling scheme to contain four scales.

# Name: ManageMapServerCacheScales.py
# Description: The following stand-alone script demonstrates how to add/delete
#               MapServer cache scales for a map service with an existing schema
#               
# 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
connectionFile = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"
server = "arcgis on MyServer_6080 (publisher)"
serviceName = "Rainfall.MapServer"
inputService = connectionFile + "\\" + server + "\\" + serviceName
scales = "250000;125000;64000;5250"

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

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


try:
    starttime = time.clock()
    result = arcpy.ManageMapServerCacheScales_server(inputService, scales) 
    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 "Updated the number of cache scales successfully for " + serviceName
    " in " + str(elapsedtime) + " sec \n on " + arg2

except Exception, 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(e.message)
report.close()
    
print "Updated Map server Cache scales "

Environments

This tool does not use any geoprocessing environments.

Licensing information

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

Related topics

  • An overview of the Caching toolset

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal