Hello Everyone,
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.
The questions I have are:
- Is there a better/more official way of doing this?
- This is a bit vague, but what could cause the upload to fail the first time it runs, but succeed every time after?
- Is there another way to do this using a different API?
- How do you cause the server to generate the hosted layer using the OGC standard?
The resources I based my solution on:
I did find this class, which seems to be exactly what I want, but it does not support standalone servers: https://pro.arcgis.com/en/pro-app/arcpy/sharing/tilesharingdraft-class.htm
The approach I'm taking, which has been simplified for the point of demonstration, is as follows:
import arcpy
project = arcpy.mp.ArcGISProject(/*Path to the Project*/)
map = project.listMaps()[0]
file_path = /* some path */
raster_layer = arcpy.MakeRasterLayer_management(/* Valid parameters supplied here */)
arcpy.SaveToLayerFile_management(raster_layer, file_path)
map.addLayer(arcpy.mp.LayerFile(file_path), "TOP")
project.save()
target_layer = map.listLayers(/* Layer name */)[0]
sharing_draft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER",
"MAP_SERVICE",
/* Layer name */,
target_layer)
sharing_draft.targetServer = /* server connection */
.
.
.
sddraft_path = /* path to sharing draft */
sharing_draft.exportToSDDraft(sddraft_path)
modify_xml(sddraft_path)
sd_path = /* path to the service definition */
stage_result = arcpy.StageService_server(sddraft_path, sd_path)
upload_result = arcpy.UploadServiceDefinition_server(stage_result.getOutput(0),
/* server connection */)
arcpy.ManageMapServerCacheTiles_server(/* valid parameters supplied here */)
Thank you for your time,
Brian