首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用python的ArcGIS发布FeatureLayer?

如何使用python的ArcGIS发布FeatureLayer?
EN

Stack Overflow用户
提问于 2019-03-01 01:29:20
回答 1查看 834关注 0票数 0

我要使用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:

代码语言:javascript
复制
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)

现在,运行这段代码的问题是它会产生以下错误:

代码语言:javascript
复制
~\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。

EN

回答 1

Stack Overflow用户

发布于 2019-03-01 03:05:55

有一个很好的示例here

您可以将点列表上传至AGOL,然后使用.publish()转到要素图层

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54931183

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档