HOW TO
Vorhandene Service-Metadaten können unter Verwendung der ArcGIS API for Python in ein neues Element in ArcGIS Online oder ArcGIS Enterprise kopiert werden. Dies kann besonders nützlich sein, um innerhalb der ganzen Organisation für Einheitlichkeit zu sorgen, wenn mehrere Daten betroffen sind.
Nachfolgend wird das Kopieren der Metadaten aus einem vorhandenen Service beschrieben. Es gibt zwei Methoden, um die Metadaten zu kopieren: aus einem Feature-Layer oder aus einem Kartenservice.
Verwenden von Feature-Layern
import arcgis from arcgis.gis import GIS from arcgis.features import FeatureLayer
gis = GIS("https://arcgis.com", "Username", "Password") url = '<Feature Layer Service URL>' layer = FeatureLayer(url)
itemTags = layer.properties.documentInfo.Keywords itemDescription = layer.properties.serviceDescription itemSnippet = layer.properties.documentInfo.Subject itemTitle = layer.properties.documentInfo.Title
wmsUrl = '<URL to the service>' props = {'title': itemTitle, 'type': 'Feature Service', 'url': '<URL to the service>', 'tags': itemTags, 'description': itemDescription, 'snippet': itemSnippet} wmsItem = gis.content.add(item_properties=props, data=wmsUrl)Im Folgenden ist ein Beispiel für das gesamte Skript dargestellt:
import arcgis from arcgis.gis import GIS from arcgis.features import FeatureLayer gis = GIS("https://arcgis.com", "Username", "Password") url = 'https://services.arcgis.com/Wl7Y1m92PbjtJs5n/arcgis/rest/services/workers_dec6d6e11b564e338fb3254626cee2f0/FeatureServer' layer = FeatureLayer(url) itemTags = layer.properties.documentInfo.Keywords itemDescription = layer.properties.serviceDescription itemSnippet = layer.properties.documentInfo.Subject itemTitle = layer.properties.documentInfo.Title wmsUrl = 'https://domain.esri.com:6443/arcgis/rest/services' props = {'title': itemTitle, 'type': 'Feature Service', 'url': 'https://domain.esri.com:6443/arcgis/rest/services', 'tags': itemTags, 'description': itemDescription, 'snippet': itemSnippet} wmsItem = gis.content.add(item_properties=props, data=wmsUrl)Verwenden eines Kartenservice
import arcgis from arcgis.gis import GIS from arcgis.mapping import MapImageLayer
gis = GIS("https://arcgis.com", "Username", "Password") url = '<Map Service URL>' layer = MapImageLayer(url)
itemTags = layer.item_info['tags'] itemDescription = layer.item_info['description'] itemSnippet = layer.item_info['summary'] itemTitle = layer.item_info['title'] itemTumbnail = layer.thumbnail()
wmsUrl = '<URL to the service>' props = {'title': itemTitle, 'type': 'Map Service', 'url': '<Url to the service>', 'tags': itemTags, 'description': itemDescription, 'snippet': itemSnippet} wmsItem = gis.content.add(item_properties=props, data=wmsUrl, thumbnail= itemTumbnail)Im Folgenden ist ein Beispiel für das gesamte Skript dargestellt:
import arcgis from arcgis.gis import GIS from arcgis.mapping import MapImageLayer gis = GIS("https://arcgis.com", "Username", "Password") url = 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/MapServer' layer = MapImageLayer(url) itemTags = layer.item_info['tags'] itemDescription = layer.item_info['description'] itemSnippet = layer.item_info['summary'] itemTitle = layer.item_info['title'] itemTumbnail = layer.thumbnail() wmsUrl = 'https://domain.esri.com:6443/arcgis/rest/services' props = {'title': itemTitle, 'type': 'Map Service', 'url': 'https://domain.esri.com:6443/arcgis/rest/services', 'tags': itemTags, 'description': itemDescription, 'snippet': itemSnippet} wmsItem = gis.content.add(item_properties=props, data=wmsUrl, thumbnail= itemTumbnail)
Hilfe von ArcGIS-Expert*innen erhalten
Die Esri Support-App herunterladen