CÓMO
Las capas web se pueden agregar a ArcGIS Online desde un directorio de servicios REST de ArcGIS existente a través de ArcGIS API for Python mediante la función gis.content.add(). Sin embargo, si la capa deseada contiene una credencial almacenada, la función se ve obstaculizada y el proceso de adición de la capa web falla.
En los siguientes pasos se describe cómo agregar una capa web con credenciales almacenadas a ArcGIS Online mediante ArcGIS API for Python.
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)
A continuación, se muestra el código completo:
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. de artículo: 000022504
Obtener ayuda de expertos en ArcGIS
Descargar la aplicación de soporte de Esri