我要使用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在深入研究代码之后,我觉得这是一个bug。然而,我的问题是:如何使用arcgis for python从头开始发布要素图层?我知道有使用arcpy的解决方案(例如create new shapefile in arcmap using python),但据我所知,arcgis将在某一时刻取代arcgis。
发布于 2019-03-01 03:05:55
有一个很好的示例here
您可以将点列表上传至AGOL,然后使用.publish()转到要素图层
https://stackoverflow.com/questions/54931183
复制相似问题