Select to view content in your preferred language

Tile layer empty when publishing raster to AGOL from ArcGIS Pro

1907
4
Jump to solution
07-11-2021 12:54 PM
DonMorrison1
Frequent Contributor

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

0 Kudos
2 Solutions

Accepted Solutions
DavidPike
MVP Frequent Contributor

It looks like those tiles are empty, but I'm not sure.  In my mind, Pro would do the heavy lifting of the caching to create the tiles ready for publishing (rather than AGOL doing it cloud-side for you - which would burn credits I would have thought).  Perhaps the script is missing this part and just uploading a definition of a cache which hasn't been created.

I'll just highlight I have no experience of AGOL tile layers so take this as just an assumption, and I'll have to tap-out of this one before I misinform anyone sorry.

View solution in original post

DonMorrison1
Frequent Contributor

You are correct - I just checked the help documentation again and saw this note which indicates that I had omitted a step:

When you save a service definition, the cache must be built manually after the web tile layer is published.

I poked around the AGOL item settings and stumbled on the "Build Tiles" buttons and clicking that did trick.  Thanks so much - I wasn't even aware that the cache existed or it was something I had to deal with until you pointed it out. 

View solution in original post

4 Replies
DavidPike
MVP Frequent Contributor

Does the tile layer schema match the basemap schema? Have you tried viewing the tile layer set as the basemap layer? What happens when you create your own request url in the a web browser with a bbox?

DonMorrison1
Frequent Contributor

I actually don't see how in Python to set the tiling scheme when creating the service. In any case, it appears that the default " ArcGIS Online/Bing Maps/Google Maps" scheme was used since there are 24 256x256 levels in the AGOL tile layer description.  

When I access the tile layer using this URL https://tiles.arcgis.com/tiles/dJOijx2lWTlGQBDJ/arcgis/rest/services/TEST_TIF_1/MapServer  and view the map,  I do not see the image . There is no base map in this case so case so I think the problem is not related to a mismatch.  

When I make the tile layer a basemap, I get the same results.

This is my first experience with tile layers so I really appreciate your suggestions.  Backing up a bit, my goal is to come up with a python script/tool that takes a .tif (perhaps other raster formats also) file and makes it available in ArcGIS Online for users to add into their maps.  Perhaps there is some other way to do it than how I'm going about it? 

0 Kudos
DavidPike
MVP Frequent Contributor

It looks like those tiles are empty, but I'm not sure.  In my mind, Pro would do the heavy lifting of the caching to create the tiles ready for publishing (rather than AGOL doing it cloud-side for you - which would burn credits I would have thought).  Perhaps the script is missing this part and just uploading a definition of a cache which hasn't been created.

I'll just highlight I have no experience of AGOL tile layers so take this as just an assumption, and I'll have to tap-out of this one before I misinform anyone sorry.

DonMorrison1
Frequent Contributor

You are correct - I just checked the help documentation again and saw this note which indicates that I had omitted a step:

When you save a service definition, the cache must be built manually after the web tile layer is published.

I poked around the AGOL item settings and stumbled on the "Build Tiles" buttons and clicking that did trick.  Thanks so much - I wasn't even aware that the cache existed or it was something I had to deal with until you pointed it out.