Dotspatial 按条件筛选专题图
public static void setColorByCondition(Map mapControl,string filter,string legendText)
{
if (mapControl.Layers.Count > 0)
{
MapPolygonLayer stateLayer = default(MapPolygonLayer);
stateLayer = (MapPolygonLayer)mapControl.Layers[0];
if (stateLayer == null)
{
MessageBox.Show("The layer is not a polygon layer.");
}
else
{
stateLayer.DataSet.FillAttributes();
PolygonScheme scheme = new PolygonScheme();
PolygonCategory category = new PolygonCategory(Color.Yellow, Color.Red, 1);
//filter = "[小班面积] < " + population + "";
category.FilterExpression = filter;
category.LegendText =legendText;// "面积 < " + population.ToString();
scheme.AddCategory(category);
stateLayer.Symbology = scheme;
}
}
else
{
MessageBox.Show("Please add a layer to the map.");
}
}
调用方法:
setColorByCondition(mapMain, " [面积] < 20", "面积小于20");