导出地图服务器缓存 (服务器)
摘要
将切片从地图缓存导出至磁盘上的文件夹中。切片可导入至其他缓存,也可独立于其父服务作为栅格数据集从 ArcGIS Desktop 中访问。
用法
-
运行此工具前,在磁盘上创建文件夹,以保存导出的切片。
语法
ExportMapServerCache_Server (server_name, object_name, data_frame, target_cache, {export_extent}, {levels}, thread_count, storage_format_type, {export_feature_class})
参数 | 说明 | 数据类型 |
server_name |
对缓存切片将被导出的服务进行托管的 ArcGIS Server 计算机。 | String |
object_name |
切片将被导出的地图服务。 | String |
data_frame |
地图服务的源数据框。 | String |
target_cache |
缓存将被导出到的目标文件夹。此文件夹不必 是已注册的服务器缓存目录。 | Folder |
export_extent (可选) |
定义要导出的切片的矩形范围。默认情况下,此范围被设置为服务的源地图的全图范围。请注意此工具的可选参数,它用于选择性地将切片导出限制为要素类边界。 | Extent |
levels [levels,...] (可选) |
导出切片时使用的比例级别列表。 | Double |
thread_count |
导出缓存时使用的地图服务实例的数量。默认情况下,使用实例的最大允许数量(对于 ArcGIS Server 服务,其默认值是 2)。如果服务器功能更强大,则可以在服务属性 中增加实例的最大允许数量,然后在运行此工具时增大此参数。 | Long |
storage_format_type |
导出的缓存的存储格式。
| String |
export_feature_class (可选) |
定义从缓存导出切片的位置的面要素类。它用于导出形状不规则的区域。 | Feature Class |
代码示例
该示例使用 ExportMapServerCache 导出用于四种比例的整个地图缓存。
# Name: ExportMapServerCache.py # Description: The following stand-alone script demonstrates how to export cache # for default number of scales of a service to a destination folder # Requirements: os, sys, time and 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 server = "MyServer" service = "Rainfall" dataFrame = "" exportExtents = "" scaleValues = [500000,250000,125000,64000] destinationCacheDir = "C:/data/temp" threadCount = "2" storageFormat = "Exploded" 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') # use "scaleValues[0]","scaleValues[-1]","scaleValues[0:3]" try: starttime = time.clock() result = arcpy.ExportMapServerCache_server(server, service, dataFrame, destinationCacheDir, threadCount , storageFormat, exportExtents, scaleValues) 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 " Exported cache successfully for mapservice " + service + " to " + destinationCacheDir + " 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) print "Exported Map server Cache " report.close()
该示例根据要素类的边界,使用 ExportMapServerCache 导出地图缓存。
# Name: ExportMapServerCache.py # Description: The following stand-alone script demonstrates how to export cache # for default number of scales of a service to a destination folder # Requirements: os, sys, time and 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 server = "MyServer" service = "Rainfall" dataFrame = "" exportExtents = "" scaleValues = [500000,250000,125000,64000] destinationCacheDir = "C:/data/temp" threadCount = "2" storageFormat = "Exploded" 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') # use "scaleValues[0]","scaleValues[-1]","scaleValues[0:3]" try: starttime = time.clock() result = arcpy.ExportMapServerCache_server(server, service, dataFrame, destinationCacheDir, threadCount , storageFormat, exportExtents, scaleValues) 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 " Exported cache successfully for mapservice " + service + " to " + destinationCacheDir + " 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) print "Exported Map server Cache " report.close()
环境
此工具不使用任何地理处理环境
相关主题
许可信息
ArcView: 是
ArcEditor: 是
ArcInfo: 是
7/10/2012