Aprx to Web Map Automation

601
0
04-04-2020 02:10 PM
AdamCurtis
New Contributor

Hello,

I am currently automating the creation of maps in ArcGIS Pro through the arcpy Python library, and I was wondering if it was possible to run a script to publish a Web Map to ArcGIS Online using an aprx project using arcpy. I have noticed for ArcMap, there is a function 'arcpy.MXDToWebMap_server' which could do this for me (as far as I understand), but I have been having trouble doing this through ArcGIS Pro. I have looked at several sources including the CreateWebLayerSDDraft, but the results in ArcGIS Online were hosted as a Feature Layer instead of a Web Map and was obtaining only my feature layer and not my geodatabase raster. I have tried something like this:

 

aprx = arcpy.mp.ArcGISProject('aprx file path')

m = aprx.listMaps()[0]

arcpy.mp.CreateWebLayerSDDraft(m,'sddraft location','projectName','MY_HOSTED_SERVICES')

arcpy.StageService_server('sddraft location', 'sd location')

arcpy.UploadServiceDefinition_server('sd location', 'My Hosted Services')

 

This may be somewhat of a duplicate of:Fully automate manual ArcGIS Pro [Share -> Web Map] workflow, but I am not understanding how to upload my aprx to the 'arcgis.mapping.WebMap' component referenced in the answer either.

 

Thanks for any help you can provide me. (Sorry if this was posted twice, I deleted the old one after accidentally marking it as assumed resolved)

0 Kudos
0 Replies