Looking to automate overwriting a hosted feature layer on Portal for ArcGIS.

311
1
Jump to solution
10-02-2018 01:15 PM
KevinChristy1
Occasional Contributor

I have a hosted feature layer that is based off of a SQL view that has been published to my Enterprise Portal (10.6.1).

The SQL view is constantly updating. I am looking to write a script that can automate taking this SQL Query Layer from ArcGIS Pro (2.2.1) and overwrite the published feature layer every x minutes, essentially updating it. I am new to trying to write scripts using the ArcGIS API for Python so I am hitting some snags.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
KevinChristy1
Occasional Contributor

Hey everyone who may or already have viewed this. Referencing some material I found from Esri, I wrote a working script that loops through a directory that contains the project folders for the projects containing the layers you want to overwrite. Mouthful right? Here are the considerations to make this script work:

  1. I made a separate folder where I placed my projects. For this script, it's the entire folder (within which is the .aprx file)
  2. Each .aprx file must have only a single layer. This is the layer that will be overwritten.
  3. The name of the map in the .aprx is designed to be the name of the hosted feature layer as you want it published. The script will tease out any spaces or special characters. Try not to leave it as "Map" unless you want your feature layer to be named as such.
  4. I haven't tested this script with publishing brand new feature layers. It is currently designed to only find the associated hosted feature layer on your portal and overwrite it.

Attached is the script. If you have any questions let me know and I will do my best to answer quickly!

Cheers.

View solution in original post

0 Kudos
1 Reply
KevinChristy1
Occasional Contributor

Hey everyone who may or already have viewed this. Referencing some material I found from Esri, I wrote a working script that loops through a directory that contains the project folders for the projects containing the layers you want to overwrite. Mouthful right? Here are the considerations to make this script work:

  1. I made a separate folder where I placed my projects. For this script, it's the entire folder (within which is the .aprx file)
  2. Each .aprx file must have only a single layer. This is the layer that will be overwritten.
  3. The name of the map in the .aprx is designed to be the name of the hosted feature layer as you want it published. The script will tease out any spaces or special characters. Try not to leave it as "Map" unless you want your feature layer to be named as such.
  4. I haven't tested this script with publishing brand new feature layers. It is currently designed to only find the associated hosted feature layer on your portal and overwrite it.

Attached is the script. If you have any questions let me know and I will do my best to answer quickly!

Cheers.

View solution in original post

0 Kudos