Select to view content in your preferred language

Retrieving / Setting symbology based on feature layer

2442
4
08-26-2013 01:06 PM
KevinYanuk
Deactivated User
Hello,

I am working on a small add-in that will retrieve information about feature layers (symbology, definition queries, etc.), which will allow users to import / export these settings between map documents.  I am looking for some guidance in collecting the symbology properties per feature layer.  I have the following code that is hit for each feature layer in a map document:

                var featureLayer = (IFeatureLayer)layer;
                var legendInfo = (ILegendInfo)featureLayer;

                for (int li = 0; li < legendInfo.LegendGroupCount; li++)
                {
                    var legendGroup = legendInfo.get_LegendGroup(li);
                    for (int lg = 0; lg < legendGroup.ClassCount; lg++)
                    {
                        var legendClass = legendGroup.get_Class(lg);
                    }
                }



Is it possible to collect symbology properties (i.e. in an .XML file), to reload into new feature layers in a new MXD?  I was looking at the IFeatureRenderer's as well - is this a better method of obtaining symbology properties?

Any advice / direction is much appreciated!  Thanks
0 Kudos
4 Replies
Santosh_Pavan_KumarNukala
Deactivated User
To add to this, as a beginner I have a very basic doubt regarding symbology. I see that when I add any of my layers through "Add Layer" button, the layer is shown with default symbology and I hence feel the need to set the symbology through feature renderer every time i want to view the layer. But when I display the feature layers in California.GDB (which is given as sample data, that comes with ArcGIS Engine installation) by selecting from "Add Data" button, the layers come up with exactly the correct symbology as expected without the need to set any renderer explicitly. I want to know how this is achieved for California.gdb, where is the symbology information stored. This is a very big doubt that has been haunting, kindly excuse for using your post to add my question.

I also have similar issue regarding how to persist the symbology while export and import of layers. Request help.

Thanks and Regards,
Pavan
0 Kudos
KevinYanuk
Deactivated User
To add to this, as a beginner I have a very basic doubt regarding symbology. I see that when I add any of my layers through "Add Layer" button, the layer is shown with default symbology and I hence feel the need to set the symbology through feature renderer every time i want to view the layer. But when I display the feature layers in California.GDB (which is given as sample data, that comes with ArcGIS Engine installation) by selecting from "Add Data" button, the layers come up with exactly the correct symbology as expected without the need to set any renderer explicitly. I want to know how this is achieved for California.gdb, where is the symbology information stored. This is a very big doubt that has been haunting, kindly excuse for using your post to add my question.

I also have similar issue regarding how to persist the symbology while export and import of layers. Request help.

Thanks and Regards,
Pavan



No problem - persisting / obtaining symbology 'data' has always seemed pretty hacky to me - in the past, I had done it in Python with symbology layers using:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006n000000

and just saving layer symbology to apply this way ... I'd really like a nice example of how this works with ArcObjects, and whether I can just use the symbology properties rather than having to constantly re-save layers and store them somewhere.
0 Kudos
Santosh_Pavan_KumarNukala
Deactivated User
No problem - persisting / obtaining symbology 'data' has always seemed pretty hacky to me - in the past, I had done it in Python with symbology layers using:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006n000000

and just saving layer symbology to apply this way ... I'd really like a nice example of how this works with ArcObjects, and whether I can just use the symbology properties rather than having to constantly re-save layers and store them somewhere.



Thanks for help, I have seen this link previously but did not know how create the "Symbology Layer". The Input Layer is the actual layer without symbology, I have a doubt on Symbology layer.. Is it a separate empty feature layer with same feature type as that of Input layer with just a field that matches one of the fields in the input layer used as criteria for symbology.. how is the difference between the colors assigned to various values in symbology layer .. renderer need to be created ?? . Once ApplySymbolgyFromLayer() is applied, the symbology is permanently applied like the case i mentioned for California.gdb when opened from Add Data button. Can you post a sample Symbology Layer and Input layer and apply it.. Request you to kindly reply with an example. plz

Regards,
Pavan
0 Kudos
Santosh_Pavan_KumarNukala
Deactivated User
Thanks for help, I have seen this link previously but did not know how create the "Symbology Layer". The Input Layer is the actual layer without symbology, I have a doubt on Symbology layer.. Is it a separate empty feature layer with same feature type as that of Input layer with just a field that matches one of the fields in the input layer used as criteria for symbology.. how is the difference between the colors assigned to various values in symbology layer .. renderer need to be created ?? . Once ApplySymbolgyFromLayer() is applied, the symbology is permanently applied like the case i mentioned for California.gdb when opened from Add Data button. Can you post a sample Symbology Layer and Input layer and apply it.. Request you to kindly reply with an example. plz

Regards,
Pavan



Can someone help on the above please.. How to create a Symbology Layer for an Input layer on which Symbology needs to be applied as mentioned in the link.

Regards,
Pavan
0 Kudos