AnsweredAssumed Answered

Create Vector Tile Package Different Results in ArcGIS Pro and Standalone Python Script

Question asked by geoffreywestgis on Feb 20, 2018

I have a script which creates a vector tile package.  I am receiving the error: ERROR 001856: Cached scale doesn't match tiling scheme only when I run the tool from a standalone Python script.  I use the same parameters in the GUI of ArcGIS Pro and the tool works fine.  Is this an ArcPy bug?  If I don't use a min and max scaling the tool runs successfully but takes forever due to the size of the dataset.

 

Here is my script:

from arcgis.gis import GIS
import os
import arcpy



#set environment settings
gis = GIS("myportal")
arcpy.env.overwriteOutput = True
outputPath = r"\\myOutPath\"
arcpy.env.parallelProcessingFactor = "66%"


# Loop through the project, find all the maps, and
#   create a vector tile package for each map,
#   using the same name as the map
p = arcpy.mp.ArcGISProject(r"\\CPVektrTile.aprx")
for m in p.listMaps():
    print("Indexing " + m.name)
    arcpy.CreateVectorTileIndex_management(m, outputPath + m.name + '.shp', "ONLINE", "", 10000)
    print("Packaging " + m.name)
    arcpy.management.CreateVectorTilePackage(m, outputPath + m.name + '.vtpk', "ONLINE", "", "INDEXED", 100000, 3000, r"\\CPAreas.shp")

print ("Adding VTPK to Test Portal")
vtpk_item = gis.content.add({}, data=outputPath + m.name + '.vtpk', folder='packages', overwrite=True)

print ("Publishing & Overwriting VTPK to Test Portal")
vtpk_layer = vtpk_item.publish(overwrite=True)
vtpk_layer.share(groups="SCG - Cathodic Protection")

 

Screenshot of successful run from geoprocessing tool in ArcGIS Pro:

 

 

Code sent to Python Window from history:

arcpy.management.CreateVectorTilePackage("CPAreas", r"C:\db\vtpktest_2.vtpk", "ONLINE", None, "INDEXED", 100000, 3000, r"\\\CPAreas.shp", None, None)

Outcomes