ThinkGeo.com    |     Documentation    |     Premium Support

Thematic Map Question

Hi,


I have an ESRI shape file with 30 columns, I need to create thematic on 27 columns, it depends which column the user selected, I need to  create the thematic map, for example:


Top 50% green


Top 20% yellow


Top 10% orange


Top 5% red.


I think I need to do a SQL query first to get the class break value. Can I do a SQL query like this:


MyShapeFileFeatureLayer.QueryTools.ExecuteQuery("Select TOP 50 Percent * From MyShapeFile Order by ColName")


So I can get the class break value from the first record and the last record.


Thanks


Rose



Rose,


Thanks for your post and sorry for the delay for some problem in the discussion forum in the past few days.
 
I think yes, you could do SQL Query like that, following code is the sample code for this:

string connectString = "Data Source=***.***.***.***;Initial Catalog=InternalDB;Persist Security Info=True;User ID=**;Password=***";
MsSql2008FeatureLayer sql2008Layer = new MsSql2008FeatureLayer(connectString, "states", "recid");
sql2008Layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
sql2008Layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
 
sql2008Layer.Open();
DataTable dataTable = sql2008Layer.QueryTools.ExecuteQuery("Select TOP 20 percent AREA From states order by AREA DESC");
sql2008Layer.Close();

 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale

Yale:


Thanks for your reply.


But my question is whether I can use the "Top" operator in the SQL query of a ShapeFileFeatureLayer instead of MsSQL2008FeatureLayer.


Thanks


Rose



Rose,


I am sorry I did not make it clear. The answer is yes, the SQL statement can also be applied to ShapeFileFeatureSource. See following codes snippet.



ShapeFileFeatureLayer usStatesLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\USStates.shp");
usStatesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
usStatesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

usStatesLayer.Open();
DataTable table = usStatesLayer.QueryTools.ExecuteQuery("Select TOP 20 percent AREA From USStates order by AREA DESC");
usStatesLayer.Close();

Any more questions just feel free to let me know.


Thanks.


Yale