I have a raster (TIFF) that I want to publish on my ArcGIS Enterprise Portal. To reach that aim, I followed these steps :

1) Create SDDraft from TIFF in ArcGIS Pro project

2) Create SD file from the draft

3) Publish Tile Layer from SD file

import arcpy
from atmo.connect import *
from shutil import copyfile

import os

#connexion au portail Cartothèque

# Set output file names
annee = '2018'
ville = 'LILLE'
outdir = dir + '/%s/%s' %(ville,annee)

print('Publication des données pour ' + ville + ' et l\'année ' + annee)
service = ville + "_"+annee+"_PM25_moy"
print('Publication des données de ' + service)
sddraft_file = outdir + '\\' + service + '.sddraft'

##### ETAPE 1 - Création du fichier SDDraft depuis un projet ArcGIS Pro

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(dir + r"/ARCGIS_projects/" + ville + '/' + ville + ".aprx")
map = aprx.listMaps("PM25_moy")[0]

# Create Tile Layer SharingDraft from map in ArcGisPro project
sharing_draft = map.getWebLayerSharingDraft("HOSTING_SERVER", "TILE", service)
print('Le brouillon de la WebLayer est créé.')

# Create Service Definition Draft file
print('Le fichier du brouillon du service de Définition est créé')

##### ETAPE 2 - Création du fichier SD (Service Definition) depuis le fichier SDDraft

# Create Service definition file
sd_file = outdir + '\\' + service + ".sd"
arcpy.StageService_server(sddraft_file, sd_file)
print('Le fichier de Service définition est créé')

##### ETAPE 3 - Publication de la couche de tuiles depuis le fichier SD

# Share to portal as Tile Layer
print("Uploading Service Definition...")
arcpy.UploadServiceDefinition_server(sd_file, "My Hosted Services")  

print("Successfully Uploaded service.")

It works well, my Tile Layer is created, but the tiles are not generated. I tried to publish them this way, with the gis package :

from arcgis.gis import GIS

# Envoi des requêtes de mise à jour de tuiles.
print("Lancement de la mise à jour des tuiles.")
#on vérifie que la TL existe
if portal.content.search("title: %s_%s_PM25_moy" % (ville,annee), "Map Image Layer") !=[]:
    layer = portal.content.search("title: %s_%s_PM25_moy" % (ville,annee), "Map Image Layer")[0]
    mapImageLayer = mapping.MapImageLayer(layer.url, portal)
    print('Update des tiles en cours')

But I do not find a function to generate the tiles, only to update them.

Does someone have an idea ?


Tile Packages are produced from ArcPro by using the Create Map Tile Package processing tool (documentation.) This tool is available from arcpy; the documentation includes python syntax examples. Once the tile package is produced, you can publish it using python.

  • Thank you for your answer. I don't get what it would change : it creates Tile Layer in both case. What is the advantage of publishing a Tile Package instead of a service definition ? – J.Delannoy Oct 8 '20 at 7:39
  • It is not necessarily an 'advantage.' it is ESRI's bundling mechanism for sending tiles up to the Enterprise Portal. Here is the difference: publishing an SDdraft file is only the "service definition" while publishing the Tile Package is uploading the imagery contents as well as the service definition. – JasonInVegas Oct 13 '20 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.