<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Proper way to generate tiled imagery layers on a standalone server? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/proper-way-to-generate-tiled-imagery-layers-on-a/m-p/832402#M3222</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm interested in taking raster data (raw files for terrain imagery), and publishing it to a standalone server through an automated python script, where the resulting layer is tiled according to my cache schematics. I have found a solution that works, but it does not seem well supported nor documented, and I'm questioning the reliability of my approach as the script seems to fail intermittently when run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The questions I have are:&lt;/P&gt;&lt;OL style="padding: 0px 0px 0px 30px;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;Is there a better/more official way of doing this?&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;This is a bit vague, but what could cause the upload to fail the first time it runs, but succeed every time after?&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;Is there another way to do this using a different API?&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;How do you cause the server to generate the hosted layer using the OGC standard?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The resources I based my solution on:&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/sharing/mapservicedraft-class.htm" style="color: #2989c5; text-decoration: none;" rel="nofollow noopener noreferrer" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/arcpy/sharing/mapservicedraft-class.htm&lt;/A&gt;&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/get-started-with-the-services-directory.htm" style="color: #2989c5; text-decoration: none;" rel="nofollow noopener noreferrer" target="_blank"&gt;https://developers.arcgis.com/rest/services-reference/get-started-with-the-services-directory.htm&lt;/A&gt;&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;A href="https://enterprise.arcgis.com/en/server/latest/administer/linux/scripting-arcgis-server-administration.htm" style="color: #2989c5; text-decoration: none;" rel="nofollow noopener noreferrer" target="_blank"&gt;https://enterprise.arcgis.com/en/server/latest/administer/linux/scripting-arcgis-server-administration.htm&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did find this class, which seems to be exactly what I want, but it does not support standalone servers:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/sharing/tilesharingdraft-class.htm" style="color: #2989c5; text-decoration: none;" rel="nofollow noopener noreferrer" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/arcpy/sharing/tilesharingdraft-class.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The approach I'm taking, which has been simplified for the point of demonstration, is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

&lt;SPAN class="comment token"&gt;#obtain a reference to the project and map&lt;/SPAN&gt;
project &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcGISProject&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;Path to the Project&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
map &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; project&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listMaps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# create the raster layer&lt;/SPAN&gt;
file_path &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; some path &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;
raster_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeRasterLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; Valid parameters supplied here &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SaveToLayerFile_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;raster_layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; file_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# add the layer to the map&lt;/SPAN&gt;
map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;addLayer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;LayerFile&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;file_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TOP"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
project&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# retrieve the layer from the map and make a&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# sharing draft from it&lt;/SPAN&gt;
target_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; Layer name &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
sharing_draft &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sharing&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CreateSharingDraft&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"STANDALONE_SERVER"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                                                 &lt;SPAN class="string token"&gt;"MAP_SERVICE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                                                 &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; Layer name &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                                                 target_layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# update the properties of the sharing draft...&lt;/SPAN&gt;
sharing_draft&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;targetServer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; server connection &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# save the sharing draft to a file&lt;/SPAN&gt;
sddraft_path &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; path to sharing draft &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;
sharing_draft&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;exportToSDDraft&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sddraft_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# The sharing draft is saved as an XML file with a different extension&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# and has options that can be modified to enable the features I want.&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# I modify the sharing draft to enable caching via "isCached" and setting&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# the min and max scale of the tile cache. Note: Setting these properties&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# does not cause the server to begin tiling the layer once it's uploaded,&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# but it does enable caching functionality in the hosted layer&lt;/SPAN&gt;
modify_xml&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sddraft_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# stage the sharing draft, converting it to a service definition&lt;/SPAN&gt;
sd_path &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; path to the service definition &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;
stage_result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;StageService_server&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sddraft_path&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sd_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# upload the service definition to the standalone server&lt;/SPAN&gt;
upload_result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UploadServiceDefinition_server&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;stage_result&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
                                                     &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; server connection &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# finally, cache the hosted layer&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ManageMapServerCacheTiles_server&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; valid parameters supplied here &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time,&lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 10:03:49 GMT</pubDate>
    <dc:creator>BrianSmith11</dc:creator>
    <dc:date>2021-12-12T10:03:49Z</dc:date>
    <item>
      <title>Proper way to generate tiled imagery layers on a standalone server?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/proper-way-to-generate-tiled-imagery-layers-on-a/m-p/832402#M3222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm interested in taking raster data (raw files for terrain imagery), and publishing it to a standalone server through an automated python script, where the resulting layer is tiled according to my cache schematics. I have found a solution that works, but it does not seem well supported nor documented, and I'm questioning the reliability of my approach as the script seems to fail intermittently when run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The questions I have are:&lt;/P&gt;&lt;OL style="padding: 0px 0px 0px 30px;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;Is there a better/more official way of doing this?&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;This is a bit vague, but what could cause the upload to fail the first time it runs, but succeed every time after?&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;Is there another way to do this using a different API?&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;How do you cause the server to generate the hosted layer using the OGC standard?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The resources I based my solution on:&lt;/P&gt;&lt;UL style="padding: 0px 0px 0px 30px;"&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/sharing/mapservicedraft-class.htm" style="color: #2989c5; text-decoration: none;" rel="nofollow noopener noreferrer" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/arcpy/sharing/mapservicedraft-class.htm&lt;/A&gt;&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/get-started-with-the-services-directory.htm" style="color: #2989c5; text-decoration: none;" rel="nofollow noopener noreferrer" target="_blank"&gt;https://developers.arcgis.com/rest/services-reference/get-started-with-the-services-directory.htm&lt;/A&gt;&lt;/LI&gt;&lt;LI style="margin: 0.2em 0px;"&gt;&lt;A href="https://enterprise.arcgis.com/en/server/latest/administer/linux/scripting-arcgis-server-administration.htm" style="color: #2989c5; text-decoration: none;" rel="nofollow noopener noreferrer" target="_blank"&gt;https://enterprise.arcgis.com/en/server/latest/administer/linux/scripting-arcgis-server-administration.htm&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did find this class, which seems to be exactly what I want, but it does not support standalone servers:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/arcpy/sharing/tilesharingdraft-class.htm" style="color: #2989c5; text-decoration: none;" rel="nofollow noopener noreferrer" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/arcpy/sharing/tilesharingdraft-class.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The approach I'm taking, which has been simplified for the point of demonstration, is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

&lt;SPAN class="comment token"&gt;#obtain a reference to the project and map&lt;/SPAN&gt;
project &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcGISProject&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;Path to the Project&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
map &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; project&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listMaps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# create the raster layer&lt;/SPAN&gt;
file_path &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; some path &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;
raster_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeRasterLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; Valid parameters supplied here &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SaveToLayerFile_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;raster_layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; file_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# add the layer to the map&lt;/SPAN&gt;
map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;addLayer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;LayerFile&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;file_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"TOP"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
project&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# retrieve the layer from the map and make a&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# sharing draft from it&lt;/SPAN&gt;
target_layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; Layer name &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
sharing_draft &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sharing&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CreateSharingDraft&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"STANDALONE_SERVER"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                                                 &lt;SPAN class="string token"&gt;"MAP_SERVICE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                                                 &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; Layer name &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                                                 target_layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# update the properties of the sharing draft...&lt;/SPAN&gt;
sharing_draft&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;targetServer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; server connection &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# save the sharing draft to a file&lt;/SPAN&gt;
sddraft_path &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; path to sharing draft &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;
sharing_draft&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;exportToSDDraft&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sddraft_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# The sharing draft is saved as an XML file with a different extension&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# and has options that can be modified to enable the features I want.&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# I modify the sharing draft to enable caching via "isCached" and setting&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# the min and max scale of the tile cache. Note: Setting these properties&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# does not cause the server to begin tiling the layer once it's uploaded,&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# but it does enable caching functionality in the hosted layer&lt;/SPAN&gt;
modify_xml&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sddraft_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# stage the sharing draft, converting it to a service definition&lt;/SPAN&gt;
sd_path &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; path to the service definition &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;
stage_result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;StageService_server&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sddraft_path&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sd_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# upload the service definition to the standalone server&lt;/SPAN&gt;
upload_result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UploadServiceDefinition_server&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;stage_result&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
                                                     &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; server connection &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# finally, cache the hosted layer&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ManageMapServerCacheTiles_server&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; valid parameters supplied here &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time,&lt;/P&gt;&lt;P&gt;Brian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:03:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/proper-way-to-generate-tiled-imagery-layers-on-a/m-p/832402#M3222</guid>
      <dc:creator>BrianSmith11</dc:creator>
      <dc:date>2021-12-12T10:03:49Z</dc:date>
    </item>
  </channel>
</rss>

