我想使用arcgis for python发布要素图层。首先,我想根据文档(https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html?highlight=import_data#arcgis.gis.ContentManager.import_data)创建shapefile:
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)
现在运行此代码的问题是它会产生以下错误:
~\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
深入研究代码后,我觉得这是一个错误。但是,我的问题是:如何使用arcgis for python从头开始发布要素图层?我了解有使用arcpy
(例如create new shapefile in arcmap using python)的解决方案,但据我所知,arcpy将在某些时候被arcgis替换为python。