操作方法
可以使用 gis.content.add() 函数通过 ArcGIS API for Python 将 Web 图层从现有 ArcGIS REST 服务目录添加到 ArcGIS Online。 但是,如果所需图层包含存储的凭据,则功能会受到阻碍,并且添加 Web 图层的过程将失败。
以下步骤介绍了如何使用 ArcGIS API for Python 将具有存储凭据的 Web 图层添加到 ArcGIS Online。
from arcgis.map import Map from arcgis.gis import GIS
gis = GIS('https://www.arcgis.com','username') token = gis._con.token
item_properties = { "title":"TestAdd2", #the same title "tags":"test", "url":"https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire_secure/FeatureServer", "type":"Feature Service", "description":"Test Me", "serviceUsername":"username", "servicePassword":"password", "token":token }
gis.content.add(data="https://sample.arcgisonline.com/",owner="username",item_properties=item_properties)
以下为完整代码:
from arcgis.map import Map from arcgis.gis import GIS gis = GIS('https://www.arcgis.com','arch0000') token = gis._con.token item_properties = { "title":"TestAdd2", #the same title "tags":"test", "url":"https://sample.arcgisonline.com/arcgis/rest/services/Wildfire_secure/FeatureServer", "type":"Feature Service", "description":"Test Me", "serviceUsername":"username", "servicePassword":"password", "token":token } gis.content.add(data="https://sample.arcgisonline.com/arcgis/rest/services/Wildfire_secure/FeatureServer",owner="username",item_properties=item_properties)
文章 ID: 000022504
获取来自 ArcGIS 专家的帮助
下载 Esri 支持应用程序