In Map Suite, the SymbolClassBreakRenderer class allows for multiple symbols to be defined that correlate to ranges or class breaks. For example, you can use class breaks to produce a map that visually shows different population sizes. You can use this powerful feature to render your maps based on many types of differing values -- this article will show you the way.
Introduction
If you need to build thematic maps (maps that provide information on a specific themes such as spatial distribution of population, timber volumes, weather, vegetation etc.) you can do so quickly and easily using the SymbolClassBreakRenderer Class in Map Suite. This article will show you the basics of getting started on your way to building your own feature rich mapping and spatial applications.
(NOTE: This article references the ClassBreakRendererApp that is available in the sample applications with both the trial and full versions of Map Suite. This article also focuses on the Winforms Edition of Map Suite but most of the concepts and all of the example code applies for the Webforms (ASP.NET) Edition as well.)
Register and download the trial version
Opening the Sample Applications in Visual Studio.NET Solution
After you have downloaded and installed the full or trial version of Map Suite, you may want to look through the sample applications and source code that are included with the installation. You can view the samples by going to the START menu...All Programs...ThinkGeo...[YOUR MAP SUITE VERSION] and choose either the VB Sample Apps Source Code or C# Sample Apps Source Code menu item. This will open a solution in Visual Studio.NET that includes all of the Map Suite Sample applications as well as the source code. You may also need to add the Map Suite Map Control to your Toolbox in the Visual Studio.NET IDE. You can do this by using the Add/Remove Items feature and browsing to the winformsedition.DLL file that resides in the installation directory of Map Suite (By default this is C:\Program Files\ThinkGeo\[The Version You Have Installed]\).
Now let's take a look at the SymbolClassBreakRenderer Class and how to use it.
Overview of the SymbolClassBreakRenderer Class
The SymbolClassBreakRenderer Class has the purpose of providing information to Map Suite in helping it determine when and how a portion of the map should be rendered based on a set of ranges or minimum and maximum values. The SymbolClassBreakRenderer is made up of two items: 1) The name of the column in the DBF that will provide the values for our class breaks and 2) a SymbolClassBreakCollection of SymbolClassBreakRenderers.ClassBreaks. For example, in the ClassBreakRendererApp sample application included with Map Suite there are several SymbolClassBreakRenderers.ClassBreaks added to a SymbolClassBreakCollection that define how the percentages of the Hispanic population within each Census tract of Travis County, Texas should be represented in terms of being rendered on the map.
Let's take a look at some sample code so that this is clearer. Our first step is to set up the map by setting the MapUnit property to the proper value, loading a Layer from a Shape File (.shp), setting the ThresholdUnit property on the Layer and creating a new Threshold that we can add our SymbolClassBreakRenderer to:
'-- Set length units for shape files
Map1.MapUnit = MapSuite.Geometry.MapLengthUnits.DecimalDegrees
Dim Layer As New Layer("C:\Program Files\ThinkGeo\YOUR MAPSUITE VERSION\sampledata\usa\austin\austintracts.shp")
'-- Set layer's length units to miles because that is what we want to work with
Layer.ThresholdUnit = ThresholdUnits.miles
'-- Only show this layer when map is zoomed in showing less than 10,000
'-- miles across
Dim Threshold As New Threshold(10000, 0)
For a more detailed explanation of the above code, shape data and DBF files, see the Map Suite Quick Start User's Guide.
Now that we have our Map, Layer and Threshold defined we can start building our SymbolClassBreakRenderer.ClassBreaks that will define how we want the map to display the percentages. To do this we will be defining a SymbolClassBreakCollection as mentioned earlier and adding SymbolClassBreakRenderer.ClassBreaks to it. In the example we want to use the below defined ranges:
| Percentage (%) |
Display As |
| Less than 15 |
Light Goldenrod Yellow |
| 15 - 30 |
Light Green |
| 30 - 45 |
Lime Green |
| 45 - 59 |
Green |
| More than 60 |
Dark Green |
Now that we know what we need to define for our class breaks, let's look at the code for accomplishing this. Note that we also introduce a new Class called the SymbolClassBreakRenderer.ClassBreakCap. It is explained further in the comments of the code and below:
'-- Define our SymbolClassBreakCollection to hold our class breaks
Dim ClassBreaks As New SymbolClassBreakCollection
'-- First break is 'below 15%'
ClassBreaks.Add(New SymbolClassBreakRenderer.ClassBreak(15, New AreaSymbol(New Pen(Color.Black), New SolidBrush(Color.LightGoldenrodYellow))))
'-- Next break is 'below 30%'
ClassBreaks.Add(New SymbolClassBreakRenderer.ClassBreak(30, New AreaSymbol(New Pen(Color.Black), New SolidBrush(Color.LightGreen))))
'-- Next break is 'below 45%'
ClassBreaks.Add(New SymbolClassBreakRenderer.ClassBreak(45, New AreaSymbol(New Pen(Color.Black), New SolidBrush(Color.LimeGreen))))
'-- Every class break needs a cap. With a cap of 60, here, we are saying
'-- that everything below the cap, or 'below 60%' (which means 45% or
'-- above but below 60%)should be displayed one way and those over the cap
'-- ('60% or above') should be displayed another way.
Dim ClassBreakCap As New SymbolClassBreakRenderer.ClassBreakCap(60, New AreaSymbol(New Pen(Color.Black), New SolidBrush(Color.DarkGreen)), New AreaSymbol(New Pen(Color.Black), New SolidBrush(Color.Green)))
'-- Add the ClassBreakCap to the SymbolClassBreakCollection
ClassBreaks.Add(ClassBreakCap)
Note that each constructor for a SymbolClassBreakRenderer.ClassBreak takes an argument of type Double as a maximum value (all values that fall below the value should be rendered) and a SymbolRenderer. The SymbolClassBreakRenderer.ClassBreakCap Class takes break value that puts a sort of end or "topper" on the class breaks by defining how to render values that fall in the range below the value and the last defined SymbolClassBreakRenderer.ClassBreak as well as the value and anything above. In the last line of code we add the SymbolClassBreakRenderer.ClassBreakCap to the SymbolClassBreakCollection.
Note, for more information on the SymbolRenderer Class, see the Map Suite QuickStart Guides.
Using the SymbolClassBreakRenderer Class
Now we can finally use the SymbolClassBreakRenderer Class by defining what column we will use from the DBF (.dbf) file that is associate with our Shape Date File (.shp). In this case, the column we want to use is 'perchisp01'. This will give us our percentages. If we provide that along with the SymbolClassBreakCollection of our class breaks, Map Suite will automatically render each area appropriately. Below is the code for doing this:
'-- Add layer and class break render to map so it can be displayed
Dim ClassBreakRenderer As New SymbolClassBreakRenderer("perchisp01", ClassBreaks)
Threshold.SymbolRenderers.Add(ClassBreakRenderer)
Layer.Thresholds.Add(Threshold)
Map1.Layers.Add(Layer)
'-- Force map to redraw completely
Map1.Refresh()
In the above code we simply create the new SymbolClassBreakRenderer as described earlier, add it to the SymbolRenderer Collection of the Threshold, add the Threshold to the Layer, and the Layer to the Map. Our last step is to call the Refresh() method of the map so that it can redraw it completely. When we run this code in the ClassBreakRenderersApp sample application, it renders like this:

As you can see, it is very easy to use SymbolClassBreakRenderers in your Map Suite application. With only a few lines of code, and some representative data, you can have professional looking thematic analysis maps to your users in very little time. Remember to check out the ClassBreakRenderersApp sample application to see this code and other features such as traversing the map with operations like Zooming, Panning, Track Zoom etc. as well as SymbolDisplayer class used for creating legends like the one shown on left side of the image above.
Other Resources
There are several other resources at ThinkGeo to help you get started to developing feature rich mapping and spatial applications for Microsoft .NET. Some of those resources are listed below. You can always reach a ThinkGeo support representative by phone toll-free at (866) 847-7510 or via email at support@thinkgeo.com.
Sample Applications
There are 35+ sample applications included with Map Suite when you download the trail version that include the source code to show you how to do various operations using the Map Suite component. It is very beneficial to go through those examples and the code. Both VB.NET and C# are included.
View the Map Suite sample applications online
Discussion Forums
The Map Suite Discussion Forums are a great place to get answers to all of your Map Suite development questions. The ThinkGeo Support Team monitors the forums daily and can help you on your way to being successful with Map Suite.
Visit the Discussion Forums online