I'm trying to automate the creation of some query layers with a toolbox and I've run into a problem that has me stumped. I need to save a particular string to each layer however I can't find a way to do it. Ideally I'd just save it the description of the layer however it looks likes the description property of the layer class has been depreciated in ArcPro. I attempted to alter the metadata however the query layers are created with metadata isReadOnly property set to true. I can't seem to find a way to programmatically add metadata to it as a result of this.
Any suggestions?
Yep, here is a code snippet
layer = arcpy.MakeQueryLayer_management(input_database=self.conn, out_layer_name=layer_name, query=strSQL, oid_fields=["id"], srid='3857') #Fails with broken geometries map.addLayer(layer[0], "TOP") md = m.Metadata() md.title = layer_name md.description = filter l = m.Metadata(map.listLayers()[0].longName) if not l.isReadOnly: l.copy(md) l.save() else: arcpy.AddMessage("Layer is read only.")
layer = arcpy.MakeQueryLayer_management(input_database=self.conn, out_layer_name=layer_name, query=strSQL, oid_fields=["id"], srid='3857') #Fails with broken geometries map.addLayer(layer[0], "TOP") md = m.Metadata() md.title = layer_name md.description = filter l = m.Metadata(map.listLayers()[0].longName)
if not l.isReadOnly: l.copy(md) l.save() else: arcpy.AddMessage("Layer is read only.")
are you using
Metadata—Metadata module | Documentation
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.