Arcpy: can't access lyr.symbology (but all other attributes fine)

3431
8
Jump to solution
06-09-2015 06:29 AM
DanOlner
New Contributor

I've just been attempting my first map automation with arcpy (relatively new to Python but a Java coder). I'm working on an open document that's got a layer with a graduated colour symbology already defined, trying to access it to make a change before outputting.

The problem: in arcpy, I have access to, as far as I can tell, all the Layer object's attributes/methods - apart from symbology and symbologyType. Brightness through to workspacePath are all there, Symbology isn't. It's also not listed in lyr.supports(). I am able to run "lyr.definitionQuery =" fine, but "if lyr.symbologyType == "GRADUATED_COLORS":..." gives me "Layer object has no attribute 'symbologyType'." Same for Symbology.

I am using Arc/Arcpy on a remote server that's hot on security. That's only thing I can think of that might be affecting object access. Or it could be something very obvious I'm missing, given I'm new to it - but shouldn't all Layer objects give me access to testing for SymbologyType, at least? And if it's not working, why are all other atttributes/methods there? Confused!

Any thoughts on anything obvious I'm missing? I'm hoping it's something simple and stupid... Thank you.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LukeWebb
Occasional Contributor III

Yes these property's are not listed in the 10.0 class documentation:

ArcGIS Desktop

But are present in the 10.1

ArcGIS Help 10.1

So its a version issue. I feel your pain on a remote secure system and Imageine upgrading will not be easy, so best of luck

I think you will have to use ArcObjects or VBA to get access to these in this version which is a lot more complex!  Hopefully someone can correct me here, but I dont think so...

View solution in original post

8 Replies
XanderBakker
Esri Esteemed Contributor

If you copy the MXD locally, does the script have access to the layer's symbology?

0 Kudos
DanOlner
New Contributor

Thank you for the reply. I think I am already using a local reference to mxd? Code is just:

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

lyr = arcpy.mapping.ListLayers(mxd)[0] #(which is my only layer)

lyr.supports("DEFINITIONQUERY")

>>true

lyr.supports("SYMBOLOGY")

lyr.supports("SYMBOLOGYTYPE")

These last two both return an error: "invalid value for layer_property... choices are..."

I may have misunderstood your question as I'm new to Python, but if you mean using a local scope variable, I think I'm doing that...?

0 Kudos
LukeWebb
Occasional Contributor III

1)

He means copy the layer (is it small, if not just grab 1 or 2 features) onto your local machine. (That is not hot on security), also save the mxd file here.

Is the issue still present in this instance?

The code above looks fine and is referring to a local document as you say, however if security is causing an issue doing this should avoid that.

2)

Python is very Case Sensitive, in the help files these are referred to as shown, have you tried referring to them in this case instead of capital letters?

definitionQuery

symbologyType

symbology

0 Kudos
DanOlner
New Contributor

Thanks. I can't copy onto a local machine. I have access to secure data and applications to use it on a remote desktop via citrix. We're not allowed to have any data locally, only work on the remote desktop.

Cheers - yes, I've been using the correct case. Arc's python script window has good autocomplete options too (that don't include symbology or symbologyType - which should be between supports and transparency!) so I'm able to see what's available.

I should check I can get the basic thing working locally for a different layer, though, you're right. I don't have my own local copy of arc, though colleagues do - I'll check on theirs. Though it's sounding like it's just not going to work on the remote server...

0 Kudos
LukeWebb
Occasional Contributor III

Hi,

I can confirm that Arcs Python Script window autocomplete options do include both 'symbology' and 'symbologyType'   as of version 10.1. (Possibly SP1)

Therefore either your doing something wrong to not get these, or you are using an older version of ArcMAP. (10.0 I guess?). These properties are new to the 10.1 line of Arc as far as I can tell.

I dont think it is caused by security, as the autocomplete would still function,

0 Kudos
DanOlner
New Contributor

Hmm, it's 10.0, yes. So - autocomplete does work for me (Brightness through to workspacePath) it's just not providing me with symbology or symbologyType. Is that a version issue, then?

Thanks for checking it works on your machine for me, much appreciated.

0 Kudos
LukeWebb
Occasional Contributor III

Yes these property's are not listed in the 10.0 class documentation:

ArcGIS Desktop

But are present in the 10.1

ArcGIS Help 10.1

So its a version issue. I feel your pain on a remote secure system and Imageine upgrading will not be easy, so best of luck

I think you will have to use ArcObjects or VBA to get access to these in this version which is a lot more complex!  Hopefully someone can correct me here, but I dont think so...

View solution in original post

DanOlner
New Contributor

Oh well - thank you for solving the problem for me, though. At least I know what's wrong now...

0 Kudos