Sunday, August 10, 2008

Quantile Thematic Mapping

In a previous post, I showed how to bind the output of a query task to a graphic layer. The graphic layer had a default symbol that was used to render the graphic features. In the following example, I would like to symbolize each feature based on an attribute value. We could use the symbolFunction property of a graphic layer, however this function is called on each graphic feature and does not have a "grand picture" of the full set. This is the case of a quantile distribution, where the features are rank-ordered and equal number of features are placed in colored bucket. Here is the result:Each country is color coded based on a quantile distribution of its area property over a specified number of classes. Here is the code:

<?xml version="1.0" encoding="utf-8"?>
numClasses="{numClasses.value as Number}"
<esri:QueryTask id="queryTask" url="http://tejas:8399/arcgis/rest/services/maps/world/MapServer/1">
<esri:Query id="query" returnGeometry="true" where="{where.text}">
<mx:Panel width="100%" height="100%" title="Quantile Thematic Mapping">
<mx:HBox width="100%" height="100%" horizontalGap="0">
<esri:Map id="map">
<esri:GraphicsLayer id="graphicsLayer"
<mx:DataGrid dataProvider="{queryTask.executeLastResult.attributes}" width="100%" height="100%">
<mx:DataGridColumn headerText="Name" dataField="NAME"/>
<mx:DataGridColumn headerText="Area" dataField="AREA"/>
<mx:TextInput id="where" text="FID < 10"/>
<mx:Button label="Query" click="queryTask.execute()"/>
<mx:ComboBox id="numClasses">

I introduced the QuantileAreaCalculator Class that intercepts the query last result and performs a quantile distribution of the features. A graphic feature is assigned to a bucket, and is assigned the symbol associated with that bucket.
That last assignment forces the graphic to redraw itself. Thus the above result.
The QuantileAreaCalculator numClasses property is bound to the numClasses combo box value, where upon a value change, the distribution is recalculated and the layer is auto refreshed. Download the full source code from here.


João Rodrigues Diniz said...

Hi there,
Is there an available ESRI online services similar to the one you have used in this sample? I can´t access the tejas:8399 server...
Otherwise, could you tell me how do I implement QueryLayer operation support in my services?

Thanks in advance,

ThunderHead said...

tejas is _my_ own internal ArcGIS server. Not sure what is online - check out Hope that helps.

Josh, Annie, and Isaiah said...

I'm having issues with the com.esri.ags.sample line finding the QuantileAreaCalculator, any help?

ThunderHead said...

Sorry for the delay - what is the problem ?