Hi, I have tried to create a service that takes polygon / envelope as a parameter and returns string that contains URL to TiledPackage that is created by the python script but I cant get even prototype working. This is my first touch to python and ArcGIS Geoprosessing.I have created python script that takes polygon to extract and package name as a parameters. Then I have default values hard coded and then I call arcpy.ExportTileCache_management with those values. As a result, I get TiledPackage that is about size 164 kb regardless what polygon I give.I have cache stored on a external USB drive.Any pointers?
# -*- coding: utf-8 -*-
import arcpy
import os
import sys
import traceback
arcpy.env.overwriteOutput = True
# Get parameters for the script
polygonToExtract = arcpy.GetParameterAsText(0)
packageName = arcpy.GetParameterAsText(1)
# Set default values for extract tool
cacheSource = r"L:\Taustakartta\Cache_taustakartta\Taustakartta\Taustakartta"
cacheTarget = r"T:\TilePackages"
cacheName = packageName
cacheType = "TILE_PACKAGE"
storageFormat = "COMPACT"
scales = "8000000;4000000;2000000;800000;300000;160000;80000;50000;25000;10000"
areaofinterest = polygonToExtract
try:
arcpy.ExportTileCache_management(cacheSource, cacheTarget, cacheName, cacheType, storageFormat, scales, polygonToExtract)
except arcpy.ExecuteError:
# Get the tool error messages
msgs = arcpy.GetMessages(2)
# Return tool error messages for use with a script tool
arcpy.AddError(msgs)
# Print tool error messages for use in Python/PythonWin
print msgs
except:
# Get the traceback object
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# Concatenate information together concerning the error into a message string
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
# Return python error messages for use in script tool or Python Window
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
# Print Python error messages for use in Python / Python Window
print pymsg + "\n"
print msgs
print "-- Script completed --"