Adding symbology from a .Style file

1626
6
02-25-2013 03:53 AM
NickFranck
New Contributor II
Hi everyone,

We have recently started automating our processes and have encountered a stumbling block. We use ArcGIS 10 with service pack 5.

The problem is: we a project for every new dossier. And for this new dossier we have to add points from old dossiers, that's where the problem is. We'd like to automate the adding of symbology since these points tend to range into the 20s. Our plan was to construct a .Style file and then create a script that would add those symbols automatically. Thus removing the repetitive task of making a symbol for every unique value of the dossier field. This would also make our process more streamlined and make the symbols universally equal.
I've done some research on this matter and have noticed that the only way to add symbols through python is by importing it from a layer file.

Does anyone have a solution for this?
Thanks in advance!

greets, Nick
Tags (2)
0 Kudos
6 Replies
JeffMoulds
Esri Contributor
At 10.1, we added a limited set of symbology properties. See the SymbologyType property of the Layer class for more information.

At 10.0, symbology must be imported from an existing .LYR file or from a layer in another map document. Perhaps you can automate this by accessing the layer from a previous dossier map document? See the UpdateLayer help topic. Use the symbology_only parameter if all you want is the symbology.

Depending on your workflow, perhaps AddLayer would also be a useful function to add a layer from a previous dossier to the new map - not sure.
0 Kudos
NickFranck
New Contributor II
Maybe I'd better give some more info.
We have a large database that is coupled to an online viewer.
Whenever we make a new dossier, we go to that viewer and extract a shapefile from the specific place we want data from. The only problem is that every new area can have a varied number of old dossiers.
I've been trying the apply symbology from layer tool but seem to be stuck on the dynamic usage part.
In the esri documentation is noted that when you apply a 'unique values symbology to a feature', The unique values are updated to reflect the input layer.
At the moment I'm only able to apply the symbology when the unique values are the same, how do you actually make the script apply to the new values of the other shapefile?

greets, Nick
0 Kudos
JeffMoulds
Esri Contributor
If I understand you correctly, the in_layer and in_symbology_layer have different values and/or number of features. And you want the in_layer to have the symbology of the in_symbology_layer, but with the values from in_layer.

If you uncheck 'All other values' in the symbology tab of the in_symbology_layer in the ArcMap user interface before running ApplySymbologyFromLayer, then you should get the result you expect. Or have you tried that already?

Moreover, if you upgrade to 10.1, the AddAllValues function on the UniqueValueSymbology class should also do what you want.
0 Kudos
NickFranck
New Contributor II
I have already tried that, but with the same result.
We're looking to upgrade to 10.1 to be able to use the new ArcPy methods.
At the moment we have a different solution to our symbology problem.
At first we make a unique values list from our dossier column, then we use that list to populate another column with a standard name per unique value of the dossier column. Those standard names have all been added to a layer file with a symbol attached to them.
After that we use the applySymbologyFromLayer_Management tool. This basically does the same, only the symbology labels have to be changed to the dossier name. But that's also a feature in 10.1, so we'll have to do it manually for the moment.

Thanks for the help!
greets, Nick
0 Kudos
LeticiaNascimento
New Contributor
If I understand you correctly, the in_layer and in_symbology_layer have different values and/or number of features. And you want the in_layer to have the symbology of the in_symbology_layer, but with the values from in_layer.

If you uncheck 'All other values' in the symbology tab of the in_symbology_layer in the ArcMap user interface before running ApplySymbologyFromLayer, then you should get the result you expect. Or have you tried that already?

Moreover, if you upgrade to 10.1, the AddAllValues function on the UniqueValueSymbology class should also do what you want.


Hello,

I am trying to set the symbology on 10.1 but neither the Apply Symbology From Layer or UniqueValuesSymbology are working. The problem is that in the Help page the scripts from the last one always starts with << if lyr.symbologyType == "UNIQUE_VALUES": >> but my symbologyType is equal to "OTHER" and I can't change! I used UpdateLayer but for some reason, it is not working either!

import arcpy.mapping as MP
lyrboias = MP.Layer(boias) 
lyrboias.name = "Boias"
molde_boias = MP.Layer("c:/GIS/Boias_molde.lyr")
MP.AddLayer(df, lyrboias, "TOP")
updateLayer = MP.ListLayers(mxd, "Boias", df)[0]   
MP.UpdateLayer(df, updateLayer, molde_boias, False)

Letícia
0 Kudos
JeffMoulds
Esri Contributor
Leticia,

If your symbologyType = "OTHER", then it means that you wont be able to alter individual symbology properties for the symbology classes that are supported in 10.1. Only a limited number of symbology classes and properties are exposed to arcpy.mapping. See the symbology and symbologyType properties of the layer class for more info.

However, you can definitely use UpdateLayer to update the symbology. Code sample #1 in the UpdateLayer help topic should do exacctly what you want.
0 Kudos