Publish a non-hosted feature layer using Python?

571
2
Jump to solution
02-22-2021 03:24 PM
Labels (1)
CassandraHiggins
New Contributor

I am trying to create a Python code that batch uploads shapefiles (from compressed folders stored on a local file location) to ArcGIS Online. The only way I know how to do this is using the .publish() method, which creates a hosted feature layer. Is there a method for uploading non-hosted shapefiles, or some sort of workaround? I'm looking for the equivalent of when you go into ArcGIS Online > Content > Add Item and upload a shapefile.

I've used Publishing SDs, Shapefiles and CSVs | ArcGIS for Developers as a reference, but it only utilizes the .publish() method.

I have a lot of shapefiles to upload, so I do not want to do it one-by-one using ArcGIS Online because that would be too time-consuming.

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Frequent Contributor

Check out arcgis.gis.ContentManager.add(). You should be able to batch upload your files that way. Just put "data='path-to-shapefile'" as one of the parameters.

- Josh Carlson
Kendall County GIS

View solution in original post

2 Replies
jcarlson
MVP Frequent Contributor

Check out arcgis.gis.ContentManager.add(). You should be able to batch upload your files that way. Just put "data='path-to-shapefile'" as one of the parameters.

- Josh Carlson
Kendall County GIS
UriGilad_EsriAu
Esri Contributor

@CassandraHiggins another way to do it would be through Pro. You can use the attached toolbox/script to publish multiple shapefiles or feature classes as individual services. The advantage of this method is that you can set symbology, labels, layer name, etc. in Pro and that will apply to the published layer.

If this answer solved your question or if you found it helpful please mark it accordingly to help others who have the same question.