I want to publish a feature layer using arcgis for python. As a first step I want to create a shapefile according to the documentation (https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html?highlight=import_data#arcgis.gis.ContentManager.import_data):
import os
import json
from IPython.display import display
from arcgis.gis import GIS
from arcgis.geometry import Point, Geometry
from arcgis.features import SpatialDataFrame
# Create an anonymous connection to ArcGIS Online
gis = GIS()
# create geometry ========================================================
geo = [Point({"x" : -118.15, "y" : 33.80, "spatialReference" : {"wkid" : 4326}})]
# create spatialdataframe ========================================================
df = SpatialDataFrame(geometry=geo);
# create feature layer from spatialdatafrme ============================
featureLayer = gis.content.import_data(df)
Now the problem with running this code is that it produces the following error:
~\AppData\Local\Continuum\anaconda3\lib\site-packages\shapefile.py in record(self, *recordList, **recordDict)
1067 fieldCount = len(self.fields)
1068 # Compensate for deletion flag
-> 1069 if self.fields[0][0].startswith("Deletion"): fieldCount -= 1
1070 if recordList:
1071 record = [recordList[i] for i in range(fieldCount)]
IndexError: list index out of range
After digging into the code I feel like this is a bug. However, my question is: How do I publish a featurelayer from scratch using arcgis for python? I understand that there are solutions for using arcpy
(e.g. create new shapefile in arcmap using python) but as far as I understand arcpy is going to be replaced by arcgis for python at some point.