Skip to content

Latest commit

 

History

History
78 lines (57 loc) · 4.56 KB

README.md

File metadata and controls

78 lines (57 loc) · 4.56 KB

update-hosted-feature-service

This Python script turns an MXD into a service definition (SD) file. Your ArcGIS.com account is searched for a matching service. The SD file is uploaded to your ArcGIS.com account, the existing service is overwritten with new content.

Note! Update as of August, 2015 - A major overhaul to the entire workflow, but it'll continue updating your hosted feature service just the same as it did previously! The script no longer requires Requests, it uses built-in Python libraries. It will now push your SD file to arcgis.com using a multipart upload (10mb chunks). This means it should support really big uploads without running out of memory!

(old)Note! This script was updated August 29, 2014 - The script no longer deletes and re-creates the feature service. It now will overwrite it in place. This means the original itemID of the feature service is maintained and any webmaps that referenced the feature service will continue to work.

See more information on the associated ArcGIS Blog post. The original blog post for ArcGIS 10.1 can be found here.

Instructions:

To update a single service

  1. Download the update.py and settings.ini files. (Hint: Click the Download ZIP button on the right)
  2. Save these files to your local working directory
  3. Note! You no longer need to download requests. The script will run using built-in Python modules now!
  4. Update the settings.ini file to values for your service. App
  5. Run the python script
c:\>c:\Python27\ArcGIS10.2\python.exe c:\myLocalDirectory\update.py
...
Starting Feature Service publish process
found Feature Service : 7ac9e68e9cd341e0a0a217590e4f6265
found Service Definition : bb2261fe2d684e7cb950c6d29372642e
Created D:\myLocalFolder\MyMaps\tempDir\MyMapService.sd
updated SD:   bb2261fe24684e7cb950c6d29372642e
successfully deleted...7ac9e68e9cd34fe0a0f217590e4f6265...
successfully updated...[{u'encodedServiceURL': u'http://services1.arcgis.com/hLJbHVsas2rDIzK0I/arcgis/rest/services/MyMapService/FeatureServer', u'jobId': u'c886b86c-46d4-4be2-95ab-32b284b72dfb', u'serviceurl': u'http://services1.arcgis.com/hLJbHVsas2rDIzK0I/arcgis/rest/services/MyMapService/FeatureServer', u'type': u'Feature Service', u'serviceItemId': u'7df087dfea1b4c7bad2ba372faeefc1c', u'size': 75344}]...
successfully shared...7df087dfea1b4c7bad2ba372faeefc1c...
finished.

To update multiple services

  1. Download the update_directory.py and settings.ini files. (Hint: Click the Download ZIP button on the right)
  2. Save these files to your local working directory
  3. Update a settings.ini file for each of your services. Create one .ini file for each service. Place these multiple .ini files in a single directory. The file names do not matter as long as you keep the .ini extension.
    App
  4. Update the directory variable on line 25 of update_directory.py to point to the directory holding your multiple .ini files (e.g. directory = r"C:\path\to\ini_files" ).
  5. Run the update_directory.py python script.

Requirements

  • ArcGIS 10.2, 10.2.1, 10.3, 10.3.1, 10.4, 10.4.1
  • Python 2.7 (not currently configured to work with Python 3+)

Resources

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

Licensing

Copyright 2013 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's license.txt file.

[](Esri Tags: ArcGIS.com Online Update Hosted Feature Services Automate Python Publish) [](Esri Language: Python)​