View feature symbol

4329
8
Jump to solution
01-04-2015 09:41 PM
BillKorbholz
New Contributor II

This seems like a simple operation, but I just can't put the pieces together. I'm trying to view the symbol (it happens to be a simple fill symbol) associated with a feature (it happens to use unique value symbology). In other words, I want to construct a UniqueValueRenderer that will tell me what the symbology of this feature is.

0 Kudos
1 Solution

Accepted Solutions
BillKorbholz
New Contributor II

Thanks to everyone who tried to help me with this. I finally stumbled over what I needed. VB.Net code fragment:

Dim pLayer As ESRI.ArcGIS.Carto.ILayer

Dim pFeatureLayer As ESRI.ArcGIS.Carto.IFeatureLayer

Dim pGFL As ESRI.ArcGIS.Carto.IGeoFeatureLayer ' This was the missing piece

Dim pUniqueRenderer As ESRI.ArcGIS.Carto.IUniqueValueRenderer

Dim pSymbol as ESRI.ArcGIS.Display.ISymbol

pLayer = ...

pFeatureLayer = pLayer

pGFL = pFeatureLayer

pUniqueRenderer = pGFL.Renderer

pSymbol = pUniqueRenderer.Symbol(pUniqueRenderer.Value(n))

View solution in original post

0 Kudos
8 Replies
BillKorbholz
New Contributor II

I forgot to mention the environment: ArcGIS 10.3 with .Net SDK.

0 Kudos
AnttiKajanus1
Regular Contributor II

Hey,

Depending on the scenario you can use create Swatches‌ from the symbol to create image from it (provide geometry type as a parameter) or check Legend ‌and SymbolDisplay‌ controls. If you can tell me a bit more on the scenario, i might be able to help a bit more.

0 Kudos
dotMorten_esri
Esri Frequent Contributor

You can pass the feature into the renderer to get the symbol. Ex:

    Symbol symbol = myUniqueValueRenderer.GetSymbol(myFeature);
    ImageSource swatch = await symbol.CreateSwatchAsync();

					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
0 Kudos
BillKorbholz
New Contributor II

Thanks for the reply, Morten. But here is my basic problem: I don't know how to create the unique value renderer in the first place. If I could do that, then getting the symbol would be quite straightforward. There has to be some combination of casts that will allow me to create a UVR for this feature set. Or maybe you're suggesting that I use something like a static UVR?

0 Kudos
DominiqueBroux
Esri Frequent Contributor

There is a UniqueValueRenderer sample in the SDK that demonstrates how to build a UniqueValueRenderer by code.

Basically:

  - instantiate a UniqueValueRenderer object

  - set the Fields collection with the fields that participate to the renderer

  - set the Infos collection with the set of { values, symbol}

0 Kudos
BillKorbholz
New Contributor II

Thanks for replying, Dominique. I don't think I've been clear regarding what I want to do. I want to see what the current symbol is associated with a feature. I don't want to change it. So I can't follow the SDK example, since it requires me to know the symbol associated with each value. That is exactly what I am trying to discover.

Looking at the ArcMap user interface, I can see each symbol associated with each value of my feature set. I just want to do the same in code.

0 Kudos
BillKorbholz
New Contributor II

Thanks to everyone who tried to help me with this. I finally stumbled over what I needed. VB.Net code fragment:

Dim pLayer As ESRI.ArcGIS.Carto.ILayer

Dim pFeatureLayer As ESRI.ArcGIS.Carto.IFeatureLayer

Dim pGFL As ESRI.ArcGIS.Carto.IGeoFeatureLayer ' This was the missing piece

Dim pUniqueRenderer As ESRI.ArcGIS.Carto.IUniqueValueRenderer

Dim pSymbol as ESRI.ArcGIS.Display.ISymbol

pLayer = ...

pFeatureLayer = pLayer

pGFL = pFeatureLayer

pUniqueRenderer = pGFL.Renderer

pSymbol = pUniqueRenderer.Symbol(pUniqueRenderer.Value(n))

0 Kudos
dotMorten_esri
Esri Frequent Contributor

Note: The above code is for ArcObjects, and not code for the ArcGIS Runtime .NET SDK - that probably explains a lot of the confusion.

0 Kudos