【问题标题】:How do I publish a FeatureLayer using ArcGIS for python?如何使用 ArcGIS for python 发布 FeatureLayer?
【发布时间】:2019-02-28 17:29:20
【问题描述】:

我想使用 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 将在某个时候被用于python 的 arcgis 取代。

【问题讨论】:

    标签: python gis publish arcgis


    【解决方案1】:

    有一个很好的例子here

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-11
      • 2018-09-04
      • 2019-02-18
      • 2016-05-11
      • 2019-03-20
      • 1970-01-01
      • 2020-03-15
      • 2018-01-25
      相关资源
      最近更新 更多