マップ サービス キャッシュの作成(Create Map Server Cache) (サーバ)

ライセンス レベル:BasicStandardAdvanced

サマリ

マップまたはイメージ サービス キャッシュ用のタイル スキーマおよびフォルダを作成します。このツールの実行後は、[マップ サービス キャッシュのタイルを管理(Manage Map Server Cache Tiles)] を実行して、タイルをキャッシュに追加できます。

使用法

構文

CreateMapServerCache_server (input_service, service_cache_directory, tiling_scheme_type, scales_type, num_of_scales, dots_per_inch, tile_size, {predefined_tiling_scheme}, {tile_origin}, {scales}, {cache_tile_format}, {tile_compression_quality}, {storage_format})
パラメータ説明データ タイプ
input_service

キャッシュを作成するマップまたはイメージ サービス。

これは、サーバとサービスの両方の情報を含む文字列です。この文字列の構築方法を確認するには、ArcCatalog を開き、カタログ ツリーでサービスを選択して、[場所] ツールバーに表示されているテキストを記録します。バックスラッシュをスラッシュに変更します(たとえば、GIS Servers/arcgis on MYSERVER (admin)/USA.MapServer)。

String
service_cache_directory

キャッシュの親ディレクトリ。この ArcGIS Server キャッシュ ディレクトリは、登録済みのものでなければなりません。

String
tiling_scheme_type

新しい(NEW)タイル スキーマまたは定義済み(PREDEFINED)のタイル スキーマの使用を選択します。このツールで新しいタイル スキーマを定義するか、または定義済みタイル スキーマ(*.xml)を参照することができます。定義済みスキーマは、[マップ サービス キャッシュ タイル スキーマの生成(Generate Map Server Cache Tiling Scheme)] ツールを実行することによって生成できます。

  • NEW縮尺レベル、イメージ形式、格納形式その他を定義するために、このツールのさまざまなパラメータを使用して新しいタイル スキーマを定義します。これがデフォルト設定です。
  • PREDEFINEDすでにディスク上に名前が存在するタイル スキーマ *.xml ファイルを指定します。[マップ サービス キャッシュ タイル スキーマの生成(Generate Map Server Cache Tiling Scheme)] ツールを使用して、タイル スキーマ ファイルを生成成することができます。
String
scales_type

タイルの縮尺を定義する方法を指定します。

  • STANDARD[縮尺レベル数](Python では num_of_scales)パラメータで定義した値に基づいて、縮尺を自動生成します。1:1,000,000 から 0.5 倍ずつ増減するレベルが使用されます。開始レベルとしては、ソース マップ ドキュメントの範囲に最も近いレベルが使用されます。たとえば、ソース マップ ドキュメントの範囲が 1:121,000,000 で、定義されている縮尺レベルが 3 の場合、マップ サービスは 1:128,000,000、1:64,000,000、1:32,000,000 の縮尺レベルでキャッシュを作成します。これがデフォルトです。
  • CUSTOMキャッシュ設計者が希望する縮尺を入力することを許可します。
String
num_of_scales

キャッシュ内に作成される縮尺レベルの数。縮尺のカスタム リストを作成した場合、このオプションは無効です。

Long
dots_per_inch

対象となる出力デバイスの 1 インチあたりのドット数。選択した DPI が出力デバイスの解像度と一致していない場合、その縮尺のマップ タイルは正しく表示されません。デフォルト値は 96 です。

Long
tile_size

キャッシュ タイルの幅と高さ(ピクセル単位)。デフォルトは 256 x 256 です。パフォーマンスと管理容易性の最適なバランスを得るには、256 x 256 または 512 x 512 の標準幅から外れないようにしてください。

Long
predefined_tiling_scheme
(オプション)

定義済みタイル スキーマ ファイル(ファイル名は通常 conf.xml)へのパス。

File
tile_origin
(オプション)

ソース マップ ドキュメントの空間参照座標での、タイル スキーマの原点(左上隅)。ソース マップ ドキュメントの範囲は、この原点の内側であることが条件となります(ただし、この領域と一致している必要はありません)。

Point
scales
[scales,...]
(オプション)

利用可能なキャッシュの縮尺レベル。これらは分数としては表されません。代わりに、500 を使用して 1:500 などの目盛を表します。

Value Table
cache_tile_format
(オプション)

キャッシュ内のタイル用に PNG、PNG8、PNG24、PNG32、JPEG、または MIXED のいずれかのファイル形式を選択します。PNG8 がデフォルトです。

  • PNGさまざまなビット深度で PNG 形式を作成します。ビット深度は、タイルのカラー バリエーションと透過値に従って最適化されます。
  • PNG88 ビット カラーの可逆イメージ形式で、インデックス カラー パレットとアルファ テーブルを使用します。各ピクセルには、値(0 - 255)が格納されていて、カラー パレット内のカラー、およびアルファ テーブル内の透過表示色のルックアップに使用されます。8 ビット PNG は、GIF イメージと類似しており、ほとんどの Web ブラウザによって、背景の透過に対する最高のサポートを得ることができます。
  • PNG243 チャンネルの可逆イメージ形式で、多くのカラー バリエーション(1,600 万色)をサポートし、透過表示も限定的にサポートします。各ピクセルには 8 ビット カラー チャンネル 3 つが格納されていて、ファイル ヘッダーには透明な背景を表す単一色が格納されています。ArcMap 内では、透明背景色を表すカラーを設定できます。バージョン 7 より前の Internet Explorer のバージョンでは、この種類の透過表示はサポートされていません。PNG24 を使用したキャッシュは、PNG8 または JPEG を使用したものに比べはるかに容量が大きいため、クライアントの処理に費やすディスク容量も、帯域幅の所要量も多くなります。
  • PNG324 チャンネルの可逆イメージ形式で、多くのカラー バリエーション(1,600 万色)と透過表示をサポートします。各ピクセルには、8 ビット カラー チャンネル 3 つと、各ピクセルの透過表示レベルを表す 8 ビット アルファ チャンネル 1 つが格納されています。PNG32 フォーマットでは、0 ~ 255 の範囲で部分的に透明なピクセルが得られるのに対し、ArcGIS Server キャッシュ生成ツールが透過表示チャンネルに書き込む値は、0(完全に透明)または 255(完全に不透明)に限られます。PNG32 を使用したキャッシュは、サポートされている他のフォーマットに比べはるかに容量が大きいため、クライアントの処理に費やすディスク容量も、帯域幅の所要量も多くなります。
  • JPEG3 チャンネルの非可逆イメージ形式で、多くのカラー バリエーション(1,600 万色)をサポートしますが、透過表示はサポートしません。各ピクセルには、8 ビット カラー チャンネル 3 つが格納されています。JPEG を使用したキャッシュは、出力品質とサイズを制御します。
  • MIXED透過表示が適用された場所すべて(つまり、データ フレームの背景が見える場所すべて)で PNG 32 を作成します。残りのタイル用に JPEG を作成します。これにより、他のキャッシュ上への重ね合わせをしつつ、平均ファイル サイズを小さく抑えられます。
String
tile_compression_quality
(オプション)

JPEG 圧縮品質を得るには、値を 1 ~ 100 の範囲で入力します。JPEG タイル フォーマットのデフォルト値は 75 で、他のフォーマットのデフォルト値は 0(ゼロ)です。

圧縮は JPEG 形式だけでサポートされます。高い値を選択すると、作成されるファイルのサイズは大きくなり、画像の品質は向上します。低い値を選択すると、作成されるファイルのサイズは小さくなり、画像の品質は低下します。

Long
storage_format
(オプション)

タイルの格納形式を決定します。

  • COMPACTタイルを、バンドルと呼ぶ大きなファイルにグループ化します。この格納形式は、格納と移動の点で、より効率的です。
  • EXPLODED各タイルを個別のファイルに格納します。
String

コードのサンプル

CreateMapServerCache(マップ サービス キャッシュの作成)の例 1

この例では、STANDARD タイプの縮尺を使って、マップ キャッシュを作成します。

# Name: CreateMapServerCache.py
# Description: The following stand-alone script demonstrates how to create map
#               using standard tiling 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
serviceCacheDirectory = "C:\\arcgisserver\\arcgiscache\\"
tilingSchemeType = "NEW"
scalesType = "STANDARD"
numOfScales = "4"
scales = ""
dotsPerInch = "96"
tileOrigin = ""
scales = ""
tileSize = "256 x 256"
cacheTileFormat = "PNG32"
tileCompressionQuality = ""
storageFormat = "COMPACT"
predefinedTilingScheme = ""


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.CreateMapServerCache_server(inputService,
                                               serviceCacheDirectory,
                                               tilingSchemeType, scalesType,
                                               numOfScales, dotsPerInch,
                                               tileSize, predefinedTilingScheme,
                                               tileOrigin, scales,
                                               cacheTileFormat,
                                               tileCompressionQuality,
                                               storageFormat)
                                              
    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 "Created cache schema with 4 scales & default properties 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)
    
print "Executed creation of Map server Cache schema "
report.close()
CreateMapServerCache(マップ サービス キャッシュの作成)の例 2

この例では、CUSTOM 縮尺を使って、マップ キャッシュを作成します。

# Name: CreateMapServerCache.py
# Description: The following stand-alone script demonstrates how to create map
#              using Custom scales & jpg image format.
# 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, string, datetime, traceback

# 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
serviceCacheDirectory = "C:\\arcgisserver\\arcgiscache"
tilingSchemeType = "NEW"
scalesType = "CUSTOM"
numOfScales = "4"
dotsPerInch = "96"
tileSize = "256 x 256"
predefinedTilingScheme = ""
tileOrigin = ""
scales = "600265;350200;225400;44000"
cacheTileFormat = "JPEG"
tileCompressionQuality = "75"
storageFormat = "COMPACT"


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.CreateMapServerCache_server(inputService,
                                               serviceCacheDirectory,
                                               tilingSchemeType, scalesType,
                                               numOfScales, dotsPerInch,
                                               tileSize, predefinedTilingScheme,
                                               tileOrigin, scales, 
                                               cacheTileFormat,
                                               tileCompressionQuality,
                                               storageFormat)
    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 "Created cache schema with custom 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)
print "Executed creation of map server Cache schema using custom scales"

report.close()
CreateMapServerCache(マップ サービス キャッシュの作成)の例 3

この例では、定義済みタイル スキーマを使って、マップ キャッシュを作成します。

# Name: CreateMapServerCache.py
# Description: The following stand-alone script demonstrates how to create map
#               using existing predefined 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
serviceCacheDirectory = "C:\\arcgisserver\\directories\\arcgiscache"
tilingSchemeType = "PREDEFINED"
scalesType = ""
tileOrigin = ""
scalesType = ""
numOfScales = ""
scales = ""
dotsPerInch = "96"
tileSize = "256 x 256"
cacheTileFormat = "MIXED"
tileCompressionQuality = "75"
storageFormat = "COMPACT"
predefinedTilingScheme = "C:/data/TilingSchemes/ArcGIS_Online_Bing_Maps_Google_Maps.xml"


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.CreateMapServerCache_server (inputService,
                                                serviceCacheDirectory,
                                                tilingSchemeType, scalesType,
                                                numOfScales, dotsPerInch,
                                                tileSize, predefinedTilingScheme,
                                                tileOrigin, scales,
                                                cacheTileFormat,
                                                tileCompressionQuality,
                                                storageFormat)

    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 "Created cache schema using predefined tiling schema 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)

print "Executed creation of map server Cache schema using tiling scheme"
report.close()

環境

このツールはジオプロセシング環境を使用していません

関連トピック

ライセンス情報

ArcGIS for Desktop Basic: ○
ArcGIS for Desktop Standard: ○
ArcGIS for Desktop Advanced: ○
9/14/2013