Upload Feature Service in Model Builder

2096
1
Jump to solution
01-31-2019 11:34 AM
MalcolmMeyer2
Occasional Contributor II

I want to upload and if need be overwrite a feature service to AGOL from Model Builder, and have the resulting data be accessible via valid GeoJSON. Is this possible and if so can someone point me in the right direction?

My feeling is after looking around that this is not possible unless I write a custom python script. How this is not possible I have no idea as it is a very basic function. My other thought is I could record a task in ArcGIS Pro where I share a map as a service - but is it then possible to deploy that task automatically from Model Builder?

If I have to write my own custom script I will likely ditch all this and just use my current ModelBuilder ->GeoJSON -> NodeJS -> CDN workflow.

0 Kudos
1 Solution

Accepted Solutions
MalcolmMeyer2
Occasional Contributor II

Yes, this is possible, though the entire process is a bit complex and takes a few steps. 

  1. From an MXD, Share, Share as Service, Publish a Service.
  2. Create an Open Data Site - or Hub site.
  3. Add the published feature service to the open data site.
  4. Now the Feature Service is accessible as valid GeoJSON.
  5. Download the python script here - GitHub - arcpy/update-hosted-feature-service: Update and overwrite a hosted feature service on ArcGI... 
  6. Edit the script settings per the instructions, using the service ID from the service you just created. It defaults to setting the service as editable, so change line 440 from
    prop.find("Value").text = "Query,Create,Update,Delete,Uploads,Editing"
    to if you dont want the data to be editable
    prop.find("Value").text = "Query"
  7. In a Toolbox, right click, add a script, name it and point it at the python script above.
  8. In your Model, drag the script tool into the model. 
  9. Now you can run a model which will update your feature service and your publicly facing GeoJSON data.

View solution in original post

0 Kudos
1 Reply
MalcolmMeyer2
Occasional Contributor II

Yes, this is possible, though the entire process is a bit complex and takes a few steps. 

  1. From an MXD, Share, Share as Service, Publish a Service.
  2. Create an Open Data Site - or Hub site.
  3. Add the published feature service to the open data site.
  4. Now the Feature Service is accessible as valid GeoJSON.
  5. Download the python script here - GitHub - arcpy/update-hosted-feature-service: Update and overwrite a hosted feature service on ArcGI... 
  6. Edit the script settings per the instructions, using the service ID from the service you just created. It defaults to setting the service as editable, so change line 440 from
    prop.find("Value").text = "Query,Create,Update,Delete,Uploads,Editing"
    to if you dont want the data to be editable
    prop.find("Value").text = "Query"
  7. In a Toolbox, right click, add a script, name it and point it at the python script above.
  8. In your Model, drag the script tool into the model. 
  9. Now you can run a model which will update your feature service and your publicly facing GeoJSON data.
0 Kudos