Skip to content

Grab updates from an online source and push those changes into an ArcGIS.com Feature Service

License

Notifications You must be signed in to change notification settings

mcordell42/AutomaticUpdatesIntoFeatureService

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

AutomaticUpdatesIntoFeatureService

The Python script grabs a point location from an external site that is constantly updating. It then pulls the feature information out, constructs a JSON object and submits an updated point to an ArcGIS.com hosted feature service. A feature service with a matching schema must already exist for this script to work correctly.

See more information on the associated ArcGIS Blog post.

Instructions

  1. Download the UpdatePointFromExternalAPI.py (Hint: Click the Download ZIP button on the right)
  2. Save the files to a local directory
  3. Setup a feature service with your ArcGIS.com account. The instructions on this blog post explain different ways to create the service. The required feature service for this example is simple; the first option of creating a service from ArcGIS Online would suffice.
  4. From My Content, click Create Layer.
  5. Select from a URL to a feature layer
  6. Enter: http://services1.arcgis.com/hLJbHVT9ZrDIzK0I/arcgis/rest/services/issSchema/FeatureServer/0
  7. Select next, accept the default extent and enter some useful tags and summary information on the final page. Remember the title, you'll need to enter this information into the Python script.
  8. Click done.
  9. Set sharing options for the service. You do not need to enable editing.
  10. Edit the Python script you saved previously and update the variables at the top of the script.
  11. A username and password that owns the service
  12. The serviceName, set previously
  13. The full URL to the feature service you just created
  14. The URL of the service to get updates from (Note - simply replacing this URL with one of your choice will probably require further script updates. See the next section for details)
  15. How long to pauseTime before updating.
  16. Run the script. As-is, it'll update the point every 5 minutes. Modify this value to your needs.

Making it Update for you

Different parts of the script need to be updated to make it work with your external content.

  1. Around line 180, a req -uest is made to get updated information from an external source. The response comes back and is loaded into a json object ( issPoint ). Depending on the API you're consuming, you may or may not have to modify this part.
  2. You'll almost certainly have to update the Y, X, and ptTime variables. The code here is specific to grabbing values out of this specific json structure. You may need to grab more information, or append this information to existing features. However you change the code, make sure you appropriately update the updatePoint function (148) and where the function is called from (194).
  3. The second bit of code to update will be the jsonPoint function inside the class (around line 66). This function is set to return a simple point object with a schema that matches the feature service being updated. Update this code with the modifications made previously so the features will update your hosted feature service layer.
  4. You may need to update the fillEmptyGeo function as well. If your hosted service is empty the first time you run the script, you'll need to update this function. The entire script works by "updating" existing features. This means you need one or more values to already exist in the service.
  5. The script has been hard coded to always update a layer with the index of "0". If the layer you're updating is not the first layer in the service (0), or you have multiple layers to update, you'll need to modify the references throughout the script.

Resources

Licensing

Copyright 2014 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)​

About

Grab updates from an online source and push those changes into an ArcGIS.com Feature Service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%