I have a map in my ArcGIS Pro project that has a single layer created from a .tif file and I want to use python to publish that as a "tile layer" in ArcGIS Online (see the code below). Everything seems to be OK but when I view the tile layer in the ArcGIS Online map viewer I don't see any of the image - although the layer shows up in the legend correctly (and the thumbnail is correct).
In the browser trace I can see the map viewer sending requests for the tiles as I zoom in and out, but some come back with "Error 422: "No tile available for the specified boundary." and the rest throw a 404 error. Any ideas on what might be wrong? I am able to see the image in the map viewer when I do what I think is the equivalent process manually from ArcGIS Pro (Share -> Web Layer -> Share Web Layer)
import os
import arcpy
SERVICE_NAME = 'TEST_TIF_1'
PROJECT_FN = r'E:\CW_Hub\temp\TEST_PROJECT.aprx'
SD_DRAFT_FN = os.path.join(arcpy.env.scratchFolder, SERVICE_NAME + ".sddraft")
SD_FN = os.path.join(arcpy.env.scratchFolder, SERVICE_NAME + ".sd")
def test_tif ():
if os.path.exists(SD_DRAFT_FN):
os.remove(SD_DRAFT_FN)
if os.path.exists(SD_FN):
os.remove(SD_FN)
aprx = arcpy.mp.ArcGISProject(PROJECT_FN)
aprx_map = aprx.listMaps()[0]
sharing_draft = aprx_map.getWebLayerSharingDraft("HOSTING_SERVER", "TILE", SERVICE_NAME)
sharing_draft.serviceName = SERVICE_NAME
sharing_draft.summary = SERVICE_NAME
sharing_draft.tags = 'test'
sharing_draft.description = SERVICE_NAME
sharing_draft.portalFolder = None
sharing_draft.overwriteExistingService = True
sharing_draft.exportToSDDraft(SD_DRAFT_FN)
print ('Staging service to %s' % (SD_FN))
arcpy.StageService_server(SD_DRAFT_FN, SD_FN)
print ('Uploading service')
arcpy.UploadServiceDefinition_server(SD_FN, "HOSTING_SERVER")
return
if __name__ == '__main__':
test_tif()
ArcGIS Pro 2.6.1