Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

Publishing and Updating an MXD #264

Closed azad456 closed 7 years ago

azad456 commented 8 years ago

Hello I have an MXD file, I want to publish it to ArcGIS Online and creat an application. I will publish it first time "manually" via Arcmap and then using Web App Builder for creating my app . I need to write a script which uploads the MXD and will overwrites the existing services in ArcGIS Online so my application will get updated as well.

I Have found this Script but I am not sure i it is the right one to use.: https://github.com/Esri/ArcREST/blob/681bdca2239e6950dc20ebd97d329fc2f1064fdf/samples/update_features.py Thanks for helping

MikeMillerGIS commented 8 years ago

Take a look at one of the solutions - http://solutions.arcgis.com/utilities/water/help/high-low-water-consumption/

they provide a process to do this using ArcRest

achapkowski commented 8 years ago

@azad456 You need to use the arcpymapping for ArcGIS Desktop or the arcpy.mp module (Pro) to create an SD file.

Check out: http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/createmapsddraft.htm

After you have the SD file, all you have to do is add the item and publish it using ArcREST.

azad456 commented 8 years ago

Thanks a lot Mike man Andrew

azad456 commented 8 years ago

Now I have made a SD file by this script : import arcpy

import arcpy

wrkspc = 'G:/HighLowWaterConsumptionA4W/Maps and GDBs/' mapDoc = arcpy.mapping.MapDocument(wrkspc + 'Byggegrunde.mxd')

con = 'GIS Servers/arcgis on MyServer_6080 (publisher).ags'

service = 'Byggegrunde' sddraft = wrkspc + service + '.sddraft' sd = wrkspc + service + '.sd' summary = 'Byggegrund' tags = 'Byggegrund, Lemvig'

analysis = arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'MY_HOSTED_SERVICES', '', True, None, summary, tags)

if analysis['errors'] == {}:

Execute StageService

arcpy.StageService_server(sddraft, sd)

else:

if the sddraft analysis contained errors, display them

print analysis['errors']

Shiould I use an JSON file for a publishing with ArcREST?

MikeMillerGIS commented 8 years ago

did you look at the function in ArcRestHelper, it does all this for you?

MikeMillerGIS commented 8 years ago

https://github.com/Esri/ArcREST/blob/master/src/arcresthelper/publishingtools.py#L1346