导出地图服务器缓存 (服务器)

摘要

用于将地图图像图层缓存的切片作为缓存数据集或切片包导出至磁盘上的文件夹中。 切片可导入至其他缓存中,也可以以独立于其父服务的方式,作为一个栅格数据集从 ArcGIS Desktop 或移动设备中进行访问。

使用情况

  • 运行此工具前,请在磁盘上创建文件夹,以保存导出的切片。

  • ArcGIS Server 帐户必须拥有对目标缓存文件夹的写入权限。 如果无法向 ArcGIS Server 帐户授予目标缓存文件夹的写入权限,但 ArcGIS Pro 客户端拥有目标缓存文件夹的写入权限,请选择从服务器复制数据 (copy_data_from_server) 参数。

  • 覆盖切片参数允许导出的切片完全覆盖目标缓存中的切片,而不是混合图像。 仍可将导出的切片限制在感兴趣区域。

参数

标注说明数据类型
输入服务

带有要导出的缓存切片的地图图像图层。 可以通过在门户中浏览至所需的服务来对其进行选择,也可以从工程窗格的门户选项卡拖放一个 web 切片图层来提供此参数。

Image Service; Map Server
目标缓存路径

缓存将被导出到的目标文件夹。 此文件夹不必是一个已注册的服务器缓存目录。 ArcGIS Server 帐户必须拥有对目标缓存文件夹的写入权限。 如果无法对服务器帐户授予目标文件夹的写入权限,但 ArcGIS DesktopArcGIS Pro 客户端拥有目标文件夹的写入权限,请选择从服务器复制数据参数。

Folder
导出缓存类型

将缓存作为缓存数据集或切片包导出。 切片包适用于 ArcGIS Runtime 和 ArcGIS Mobile 部署。

  • 缓存数据集使用 ArcGIS Server 生成的地图或影像服务缓存。 其可用于 ArcGIS Desktop 并通过 ArcGIS Server 地图或影像服务对其进行使用。 这是默认设置。
  • 切片包将缓存数据集作为图层添加并合并以便实现共享的单个压缩文件。 其可用于 ArcGIS Desktop、ArcGIS Runtime 和移动应用程序。
String
从服务器复制数据

只在以下情况下选中此参数:无法向 ArcGIS Server 帐户授予目标文件夹的写入权限,但 ArcGIS DesktopArcGIS Pro 客户端拥有目标文件夹的写入权限。 软件会在将服务器输出目录中的切片移至目标文件夹前将其导出。

  • 选中 - 将切片放入服务器输出目录中,随后将其移至目标文件夹。 ArcGIS Desktop 客户端必须具有对目标文件夹的写入权限。
  • 未选中 - 切片被直接导出到目标文件夹。 ArcGIS Server 帐户必须具有对目标文件夹的写入权限。
Boolean
存储格式类型

导出的缓存的存储格式。

  • 紧凑型切片被组织到包和 bundlex 文件中以节省磁盘空间并允许以较快的速度复制缓存。 如果将导出缓存类型参数设置为切片包,则此为默认设置。
  • 紧凑型 V2仅能将切片组织到包文件中。 这种格式使得网络共享和云存储目录拥有了更好的性能。 如果将导出缓存类型参数设置为切片包,则切片包的扩展名为较新版本的 ArcGIS 平台,如 ArcGIS OnlineArcGIS Enterprise 11.2ArcGIS Runtime 100.5 均支持的 (.tpkx)。
  • 松散型每个文件都将作为单个文件进行存储(在 ArcGIS Server 之前的版本中,均以这种方式存储缓存)。
String
比例

导出切片时使用的比例级别列表。

Double
缓存服务实例数
(可选)

指定用于更新或生成切片的实例数。 该参数的值将设置为无限 (-1),且无法进行修改。

Long
感兴趣区域
(可选)

对从缓存中导出切片的位置进行空间约束的感兴趣区。 由于该工具在像素级别上裁剪缓存数据集,所以此参数在您想要导出形状不规则的区域时非常有用。

若未指定感兴趣区,则会导出地图的全图范围。

Feature Set
导出范围
(可选)

定义要导出的切片的矩形范围。 默认情况下,此范围将设置为要导入切片所属的地图服务的全图范围。 请注意此感兴趣区工具中的可选参数,它允许您使用面要素进行导入操作。 建议不要为一个作业的两个参数都提供值。 如果为两个参数都提供了值,则感兴趣区参数的优先级高于导入范围

  • 当前显示范围 地图视图 - 范围基于活动地图或场景。 仅在存在活动地图时,才可使用此选项。
  • 图层范围 图层 - 范围基于活动地图图层。 使用下拉列表选择可用图层,或使用所有图层中数据的范围选项获取所有活动地图图层(不包括底图)的组合范围。 仅在存在具有图层的活动地图时,才可使用此选项。
  • 浏览 浏览 - 范围基于现有数据集。
  • 重置范围 重置 - 将范围重置为默认值。
  • 手动输入坐标 - 坐标必须是数值,并且与活动地图的坐标系相匹配。

    地图可能使用不同的显示单位

Extent
覆盖切片
(可选)

指定接收缓存中的图像是与原始缓存中的切片合并,还是被其覆盖。

  • 选中 - 导出过程会替换感兴趣区域的所有像素,并用原始缓存中的切片有效覆盖目标缓存中的切片。
  • 未选中 - 导出切片后,默认情况下将忽略原始缓存中的透明像素。 将导致目标缓存中的图像合并或混合。 这是默认设置。
Boolean

派生输出

标注说明数据类型
输出缓存路径

缓存已被导出到的目标文件夹。

String

arcpy.server.ExportMapServerCache(input_service, target_cache_path, export_cache_type, copy_data_from_server, storage_format_type, scales, {num_of_caching_service_instances}, {area_of_interest}, {export_extent}, {overwrite})
名称说明数据类型
input_service

带有要导出的缓存切片的地图图像图层。

Image Service; Map Server
target_cache_path

缓存将被导出到的目标文件夹。 此文件夹不必是一个已注册的服务器缓存目录。 ArcGIS Server 帐户必须拥有对目标缓存文件夹的写入权限。 如果无法对服务器帐户授予目标文件夹的写入权限,但 ArcGIS DesktopArcGIS Pro 客户端拥有目标文件夹的写入权限,请选择从服务器复制数据参数。

Folder
export_cache_type

将缓存作为缓存数据集或切片包导出。 切片包适用于 ArcGIS Runtime 和 ArcGIS Mobile 部署。

  • CACHE_DATASET使用 ArcGIS Server 生成的地图或影像服务缓存。 其可用于 ArcGIS Desktop 并通过 ArcGIS Server 地图或影像服务对其进行使用。 这是默认设置。
  • TILE_PACKAGE将缓存数据集作为图层添加并合并以便实现共享的单个压缩文件。 其可用于 ArcGIS Desktop、ArcGIS Runtime 和移动应用程序。
String
copy_data_from_server

在以下情况,请将此参数设置为 COPY_DATA:无法向 ArcGIS Server 帐户授予目标文件夹的写入权限,但 ArcGIS DesktopArcGIS Pro 客户端拥有目标文件夹的写入权限。 软件会在将服务器输出目录中的切片移至目标文件夹前将其导出。

  • COPY_DATA将切片放到服务器输出目录中,随后将其移至目标文件夹。 ArcGIS DesktopArcGIS Pro 客户端必须具有对目标文件夹的写入权限。
  • DO_NOT_COPY将切片直接导出到目标文件夹。 ArcGIS Server 帐户必须具有对目标文件夹的写入权限。 这是默认设置。
Boolean
storage_format_type

导出的缓存的存储格式。

  • COMPACT切片被组织到包和 bundlex 文件中以节省磁盘空间并允许以较快的速度复制缓存。 若将 export_cache_type 参数设置为 Tile package,则此为默认设置。
  • COMPACT_V2仅能将切片组织到包文件中。 这种格式使得网络共享和云存储目录拥有了更好的性能。 如果将 export_cache_type 参数设置为 Tile package,则切片包的扩展名为较新版本的 ArcGIS 平台,如 ArcGIS OnlineArcGIS Enterprise 11.2ArcGIS Runtime 100.5 均支持的 (.tpkx)。
  • EXPLODED每个文件都将作为单个文件进行存储(在 ArcGIS Server 之前的版本中,均以这种方式存储缓存)。
String
scales
[scales,...]

导出切片时使用的比例级别列表。

Double
num_of_caching_service_instances
(可选)

指定用于更新或生成切片的实例数。 该参数的值将设置为无限 (-1),且无法进行修改。

Long
area_of_interest
(可选)

对从缓存中导出切片的位置进行空间约束的感兴趣区。 由于该工具在像素级别上裁剪缓存数据集,所以此参数在您想要导出形状不规则的区域时非常有用。

若未指定感兴趣区,则会导出地图的全图范围。

Feature Set
export_extent
(可选)

定义要导出的切片的矩形范围。 默认情况下,此范围将设置为要导入切片所属的地图服务的全图范围。 请注意此感兴趣区工具中的可选参数,它允许您使用面要素进行导入操作。 建议不要为一个作业的两个参数都提供值。 如果为两个参数都提供了值,则感兴趣区参数的优先级高于导入范围

  • MAXOF - 将使用的所有输入的最大范围。
  • MINOF - 将使用的所有输入共用的最小范围。
  • DISPLAY - 范围与可见显示范围相等。
  • 图层名称 - 将使用指定图层的范围。
  • Extent 对象 - 将使用指定对象的范围。
  • 以空格分隔的坐标字符串 - 将使用指定字符串的范围。 坐标按 x-min、y-min、x-max、y-max 的顺序表示。
Extent
overwrite
(可选)

指定接收缓存中的图像是与原始缓存中的切片合并,还是被其覆盖。

  • OVERWRITE导出过程会替换感兴趣区域的所有像素,并用原始缓存中的切片有效覆盖目标缓存中的切片。
  • MERGE导入切片后,默认情况下将忽略原始缓存中的透明像素。 将导致目标缓存中的图像合并或混合。 这是默认设置。
Boolean

派生输出

名称说明数据类型
output_cache_path

缓存已被导出到的目标文件夹。

String

代码示例

ExportMapServerCache 示例 1(独立脚本)

将存储格式从 EXPLODED 更改为 COMPACT 时导出某一要素类的缓存切片。

# Name: ExportMapServerCache.py for ArcGIS Server
# Description: The following stand-alone script demonstrates how to export
# 		cache as CACHE_DATASET in COMPACT storage format and MERGE tiles
#               using an AREA_OF_INTEREST to TARGET_CACHE_PATH
#		which is accessible to server instances
# 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
connectionFile = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"
server 			= "arcgis on MyServer_6080 (publisher)"
serviceName 		= "Rainfall.MapServer"
inputService 		= connectionFile + "\\" + server + "\\" + serviceName
targetCachePath 	= "C:/data/temp"
exportCacheType 	= "CACHE_DATASET"
copyDataFromServer 	= "DO_NOT_COPY"
storageFormat 		= "COMPACT"
scales 			= [500000,250000,125000,64000]
numOfCachingServiceInstances = "2"
areaOfInterest 		= "C:/data/101/Portland/Metro.shp"
exportExtents 		= ""
overwriteTiles 		= "MERGE"

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]"

# Enter rectangular custom extent values for the "exportExtents" variable to
# constrain the exporting cache along the rectangular extents

try:
    starttime = time.clock()
    result = arcpy.server.ExportMapServerCache(inputService, targetCachePath,
                                               exportCacheType,
                                               copyDataFromServer,
                                               storageFormat, scales,
                                               numOfCachingServiceInstances,
                                               areaOfInterest, exportExtents,
					       overwriteTiles)
    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 " + serviceName + \
        " to " + targetCachePath + "\n using " + areaOfInterest + "\n 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 \n" "Line %i" % tb.tb_lineno)
    report.write(str(e))

print("Exported Map server Cache  using area of Interest")

report.close()
ExportMapServerCache 示例 2(独立脚本)

ArcGIS Server 实例无法访问目标文件夹时将缓存导出为 TILE_PACKAGE

# Name: ExportMapServerCache.py
# Description: The following stand-alone script demonstrates how to export cache
#               as TILE_PACKAGE for default number of scales of a service, to a
#               TARGET_CACHE_PATH which is inaccessible to server instances using
#               COPY_DATA_FROM_SERVER
# 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
connectionFile = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"
server = "arcgis on MyServer_6080 (publisher)"
serviceName = "Rainfall.MapServer"
inputService = connectionFile + "\\" + server + "\\" + serviceName
targetCachePath = "C:/temp/usa"
exportCacheType = "TILE_PACKAGE"
copyDataFromServer = "COPY_DATA"
storageFormat = "COMPACT"
scaleValues = [500000,250000,125000,64000]
numOfCachingServiceInstances = "2"
exportExtents = ""
areaOfInterest = ""
overwriteTiles = "MERGE"

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.server.ExportMapServerCache(inputService, targetCachePath,
                                               exportCacheType,
                                               copyDataFromServer,
                                               storageFormat, scales,
                                               numOfCachingServiceInstances,
                                               areaOfInterest,
                                               exportExtents, overwriteTiles)
    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 " + serviceName + " to " + \
        targetCachePath + " 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("Exported Map server Cache ")

report.close()

环境

此工具不使用任何地理处理环境。

许可信息

  • Basic: 是
  • Standard: 是
  • Advanced: 是

相关主题