Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 : LayerObject: Get attribute renderer does not exist

Could you please help me. Thank you in advance,

Ronny

share|improve this question
    
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 Jul 12 '13 at 3:34
add comment

1 Answer 1

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)
share|improve this answer
    
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 Jun 30 '13 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 Jul 1 '13 at 2:50
    
Was tenorstyle.lyr a "geostatistical layer" in your test? I'm thinking that's the "non-routine" thin involved in what otherwise looks like an easy question. (+1) for running a test that shows that at least most of what is in the question works. –  PolyGeo Jul 12 '13 at 3:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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