ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

导入地图服务器缓存

  • 摘要
  • 用法
  • 语法
  • 代码示例
  • 环境
  • 许可信息

摘要

将切片从磁盘上的文件夹中导入到地图或影像服务缓存。

源文件夹可以是已注册的服务器缓存目录的子文件夹、之前已向其导出缓存的文件夹或切片包 (.tpk)。目标服务必须与源缓存使用相同的切片方案和存储格式。

用法

    注:

    在 10.1 版本中,此工具的各个参数都发生了变化。在 10.1 版本之前使用该工具编写的模型或脚本均需要经过修改才能在 10.1 版本中使用。

    在迁移至 10.1 Service Pack 1 时,必须打开并验证使用该工具的模型,因为该工具具有新参数。此过程将在使用地理处理工具自动执行缓存创建和更新中进行说明。

  • 使用此工具将全部或部分缓存从一个文件夹导入到另一个文件夹。
  • Overwrite Tiles 参数允许导入的切片完全覆盖现有的切片,而不是混合图像。仍可将导入的切片限制在感兴趣区域。

    在 10.1 Service Pack 1 中,向该工具中添加了此参数。

语法

ImportMapServerCache_server (input_service, source_cache_type, {source_cache_dataset}, {source_tile_package}, {upload_data_to_server}, {scales}, {num_of_caching_service_instances}, {area_of_interest}, {import_extent}, {overwrite})
参数说明数据类型
input_service

要向其导入切片的地图或影像服务。

这是一个包含服务器和服务器信息的字符串。要查看构建此字符串的方法,请打开 ArcCatalog,选择目录树中的服务,并注意位置 工具条中的文本。将反斜线改为正斜线,例如 GIS Servers/arcgis on MYSERVER (admin)/USA.MapServer。

Image Service; MapServer
source_cache_type

选择将缓存从缓存数据集或切片包导入到服务器上运行的缓存地图或影像服务。

  • CACHE_DATASET —使用 ArcGIS Server 生成的地图或影像服务缓存。在 ArcMap 中且通过 ArcGIS Server 地图或影像服务可用。
  • TILE_PACKAGE —将缓存数据集作为图层添加并合并以便实现轻松共享的单个压缩文件。适用于 ArcGIS Desktop 以及 ArcGIS Runtime 和移动应用程序。
String
source_cache_dataset
(可选)

与数据框名称相匹配的缓存文件夹的路径。您不必输入已注册的服务器缓存目录;实际上,多数情况下需要输入磁盘上之前已导入切片的位置。ArcGIS Server 帐户应能访问此位置。如果无法向 ArcGIS Server 帐户授予此位置的访问权限,请将 upload_data_to_server 设置为 UPLOAD_DATA。

Raster Dataset
source_tile_package
(可选)

将导入的切片包 (.tpk) 所在的路径。ArcGIS Server 帐户应能访问此位置。将切片包文件导入到缓存地图/影像服务时,upload_data_to_server 参数被忽略,因为它将被自动设置为 UPLOAD_DATA。

File
upload_data_to_server
(可选)

如果 ArcGIS Server 帐户没有源缓存的读取权限,请将此参数设置为 UPLOAD_DATA。工具会在源缓存移至 ArcGIS Server 缓存目录前将其上传到 ArcGIS Server 上传目录。

  • UPLOAD_DATA —将切片放到服务器上传目录中,随后将其移至服务器缓存目录。storage_format_type 为 TILE_PACKAGE 时,该选项默认为已启用。
  • DO_NOT_UPLOAD —将切片直接导入服务器缓存目录。ArcGIS Server 帐户必须有源缓存的读取权限。
Boolean
scales
[scales,...]
(可选)

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

Double
num_of_caching_service_instances
(可选)

专用于运行该工具的 System/CachingTools 服务实例的总数。您可以通过 ArcGIS Server 的管理连接,使用服务编辑器窗口,增加 System/CachingTools 服务的每台计算机的最大实例数。确保您的服务器计算机可以支持所选数量的实例。

Long
area_of_interest
(可选)

对将切片导入到缓存时所处的位置进行空间约束的感兴趣区。此参数在您想要导入形状不规则区域的切片时非常有用,因为该工具会按像素分辨率裁剪与面相交的缓存数据集,然后将其导入到服务器缓存目录。

如果未提供该参数的值,则将使用导入范围参数的值。默认情况下将使用地图的全图范围。

Feature Set
import_extent
(可选)

定义要导入到缓存的切片的矩形范围。默认情况下,此范围被设置为要导入切片所属的地图服务的全图范围。请注意此感兴趣区工具中的可选参数,此工具允许您使用不规则的形状对所导入的切片进行空间约束。如果为两个参数都提供了值,则感兴趣区的优先级高于导入范围。

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

派生输出

名称说明数据类型
out_job_url

字符串

代码示例

ImportMapServerCache 示例 1(独立脚本)

将缓存数据集导入到默认比例级数的缓存服务。接收缓存中的切片将被正在导入的切片所覆盖。

# Name: ImportMapServerCache.py
# Description: The following stand-alone script demonstrates how to import map
# server cache from a source directory with CACHE_DATASET and  OVERWRITE
# existing cache on the service for the number of scales specified without
# Uploading data to 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
sourceCacheType     = "CACHE_DATASET"
sourceCacheDataset  = "C:/data/destination_folder/Layers"
sourceTilePackage   = ""
uploadDataToServer  = "DO_NOT_UPLOAD"
scales              = [500000,250000,125000,64000]
numOfCachingServiceInstances = "2"
areaOfInterest      = ""
importExtents       = ""
overwriteTiles      = "OVERWRITE"

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 "scales[0]","scales[-1]","scales[0:3]"

try:
    starttime = time.clock()
    result = arcpy.ImportMapServerCache_server(inputService, sourceCacheType,
                                               sourceCacheDataset,
                                               sourceTilePackage,
                                               uploadDataToServer, scales,
                                               numOfCachingServiceInstances,
                                               areaOfInterest, importExtents,
                                               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 "Imported Map server Cache Tiles successfully for" + serviceName +\
    " from" + sourceCacheDataset + " in " + str(elapsedtime)+ "sec 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 "Imported Map server Cache Tiles "

report.close()
ImportMapServerCache 示例 1(独立脚本)

将感兴趣区的缓存切片从切片包导入到缓存服务。

# Name: ImportMapServerCache.py
# Description: The following stand-alone script demonstrates how to import map
#               server cache from a source directory with Tile Package to an existing service for 
#               the default number of scales specified using an AOI by uploading data to remote server
# To Import cache tiles for the scales specified for given feature class

# Requirements: os, sys, time and traceback modules
# Author: ESRI

# 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
sourceCacheType = "TILE_PACKAGE"
sourceCacheDataset = ""
sourceTilePackage = "C:/data/destination_folder/TPK/Rainfall.tpk"
uploadDataToServer = "UPLOAD_DATA"
scales = [500000,250000,125000,64000]
numOfCachingServiceInstances = "2"
cacheDir = "C:/arcgisserver/arcgiscache"
areaOfInterest = "C:/data/101/Portland/Portland_Metro.shp"
importExtents = ""
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 "scales[0]","scales[-1]","scales[0:3]"

try:
    starttime = time.clock()
    result = arcpy.ImportMapServerCache_server(inputService, sourceCacheType,
                                               sourceCacheDataset,
                                               sourceTilePackage,
                                               uploadDataToServer, scales,
                                               numOfCachingServiceInstances,
                                               areaOfInterest, importExtents,
					       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 "Imported Map server Cache Tiles successfully for " + serviceName +\
    " from " + sourceTilePackage + " to " + cacheDir + " using " +\
    areaOfInterest + " in " + str(elapsedtime) + " sec 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 2 \n" "Line %i" % tb.tb_lineno)
    report.write(e.message)
report.close()

print "Imported Map server Cache Tiles for the given feature class"

环境

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

许可信息

  • ArcGIS Desktop Basic: 是
  • ArcGIS Desktop Standard: 是
  • ArcGIS Desktop Advanced: 是

相关主题

  • 缓存工具集概述

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2019 Esri. | 隐私政策 | 法律声明