0

I'm quite new in using Python in Arcgis 10. I wanted to use the symbology of a geostatistical layer in the TOC in another geostatistical layer in the TOC. Therefore, one should use arcpy.mapping.updatelayer. I saved the geostatistical layer as Layer file (TensorStyle.lyr). The code to copy the symbology looks like

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")

df = arcpy.mapping.ListDataFrames(mxd)[0]

updateLayer = arcpy.mapping.ListLayers(mxd, "*", df)

sourceLayer = arcpy.mapping.Layer("TensorStyle.lyr")

for lyr in updateLayer:

    arcpy.mapping.UpdateLayer(df, lyr, sourceLayer)

If I run the script I get the message:

Runtime error <type 'exceptions.AttributeError'>: LayerObject: Get attribute renderer does not exist

Can you help me?

1
  • I've guessed that you are using the Geostatistical Analyst extension installed, but can you confirm that is the case, please? Its as if the layerfile has been created using that extension and then you are trying to use it on a machine without that extension licensed and installed.
    – PolyGeo
    Commented Jul 12, 2013 at 3:34

1 Answer 1

2

I just tried it on a few sample shapefiles and it is working for me in 10.1 SP1, both with the .lyr file in TOC and referencing its location on disk. If either option still doesn't work for you, maybe the symbology is incompatible. Try a really simple symbology and go from there.

If you are referencing it in the TOC:

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
updateLayer = arcpy.mapping.ListLayers(mxd, "*", df)
sourceLayer = arcpy.mapping.Layer("TenorStyle") #Note that .lyr is NOT included
for lyr in updateLayer:
    arcpy.mapping.UpdateLayer(df, lyr, sourceLayer)

If you are referencing the location on disk:

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
updateLayer = arcpy.mapping.ListLayers(mxd, "*", df)
sourceLayer = arcpy.mapping.Layer("D:/Data/TenorStyle.lyr") #Note that .lyr is included
for lyr in updateLayer:
    arcpy.mapping.UpdateLayer(df, lyr, sourceLayer)
3
  • Hello Paul,thank you very much for the fast response. But unfortunately, this code is also not working and Python gives the same reponse: Runtime error <type 'exceptions.AttributeError'>: LayerObject: Get attribute renderer does not exist. Anyway, thank you and my best regards, Ronny
    – Ronny
    Commented Jun 30, 2013 at 17:40
  • Well, without your sample data, I'm not really sure. Your best bet would be to try a really simple symbology on different files and see if that works. If it doesn't, it might be your version of ArcMap.
    – Paul
    Commented Jul 1, 2013 at 2:50
  • Was tenorstyle.lyr a "geostatistical layer" in your test? I'm thinking that's the "non-routine" thing involved in what otherwise looks like an easy question.
    – PolyGeo
    Commented Jul 12, 2013 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.