ArcEngine栅格和矢量渲染(含可视化颜色带)
使用ArcEngine9.3开发的栅格和矢量的渲染。
开发环境:ArcEngine9.3,VS2008。
功能:栅格(拉伸和分级)和矢量(简单、唯一值、分级、比例)渲染。
开发界面如图所示。

图1 主界面

图2 栅格渲染界面

图3 矢量渲染界面
部分源码:
按 Ctrl+C 复制代码
public void SimpleRenderer(IFeatureLayer featLayer, string fieldName, IColorRamp colorRamp)
{
IGeoFeatureLayer pGeoFeatureLayer = featLayer as IGeoFeatureLayer;
IFeatureClass pFeatureClass = featLayer.FeatureClass; //获取图层上的featureClass
IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
IUniqueValueRenderer pUniqueValueRenderer = new UniqueValueRendererClass(); //唯一值渲染器
//设置渲染字段对象
pUniqueValueRenderer.FieldCount = 1;
pUniqueValueRenderer.set_Field(0, fieldName);
ISimpleFillSymbol pSimFillSymbol = new SimpleFillSymbolClass(); //创建填充符号
pUniqueValueRenderer.DefaultSymbol = (ISymbol)pSimFillSymbol;
pUniqueValueRenderer.UseDefaultSymbol = false;
int n = pFeatureClass.FeatureCount(null);
for (int i = 0; i < n; i++)
{
IFeature pFeature = pFeatureCursor.NextFeature();
IClone pSourceClone = pSimFillSymbol as IClone;
ISimpleFillSymbol pSimpleFillSymbol = pSourceClone.Clone() as ISimpleFillSymbol;
string pFeatureValue = pFeature.get_Value(pFeature.Fields.FindField(fieldName)).ToString();
pUniqueValueRenderer.AddValue(pFeatureValue, "", (ISymbol)pSimpleFillSymbol); } //为每个符号设置颜色 for (int i = 0; i <= pUniqueValueRenderer.ValueCount - 1; i++)
{
string xv = pUniqueValueRenderer.get_Value(i); if (xv != "")
{
ISimpleFillSymbol pNextSymbol = (ISimpleFillSymbol)pUniqueValueRenderer.get_Symbol(xv);
pNextSymbol.Color = colorRamp.get_Color(127);
pUniqueValueRenderer.set_Symbol(xv, (ISymbol)pNextSymbol);
}
} pGeoFeatureLayer.Renderer = (IFeatureRenderer)pUniqueValueRenderer;
} public void UniqueRenderer(IFeatureLayer featLayer, string fieldName, IColorRamp colorRamp)
{
IGeoFeatureLayer pGeoFeatureLayer = featLayer as IGeoFeatureLayer;
IFeatureClass pFeatureClass = featLayer.FeatureClass; //获取图层上的featureClass
IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
IUniqueValueRenderer pUniqueValueRenderer = new UniqueValueRendererClass(); //唯一值渲染器
//设置渲染字段对象
pUniqueValueRenderer.FieldCount = 1;
pUniqueValueRenderer.set_Field(0, fieldName);
ISimpleFillSymbol pSimFillSymbol = new SimpleFillSymbolClass(); //创建填充符号
pUniqueValueRenderer.DefaultSymbol = (ISymbol)pSimFillSymbol;
pUniqueValueRenderer.UseDefaultSymbol = false;
int n = pFeatureClass.FeatureCount(null);
for (int i = 0; i < n; i++)
{
IFeature pFeature = pFeatureCursor.NextFeature();
IClone pSourceClone = pSimFillSymbol as IClone;
ISimpleFillSymbol pSimpleFillSymbol = pSourceClone.Clone() as ISimpleFillSymbol;
string pFeatureValue = pFeature.get_Value(pFeature.Fields.FindField(fieldName)).ToString();
pUniqueValueRenderer.AddValue(pFeatureValue, "", (ISymbol)pSimpleFillSymbol); } //为每个符号设置颜色 for (int i = 0; i <= pUniqueValueRenderer.ValueCount - 1; i++)
{
string xv = pUniqueValueRenderer.get_Value(i); if (xv != "")
{
ISimpleFillSymbol pNextSymbol = (ISimpleFillSymbol)pUniqueValueRenderer.get_Symbol(xv);
//pColor = ramp.get_Color(j * (ramp.Size - 1) / (count - 1));
pNextSymbol.Color = colorRamp.get_Color(i * (colorRamp.Size-1) / (pUniqueValueRenderer.ValueCount-1));
pUniqueValueRenderer.set_Symbol(xv, (ISymbol)pNextSymbol);
}
} pGeoFeatureLayer.Renderer = (IFeatureRenderer)pUniqueValueRenderer;
} public void ClassRenderer(IFeatureLayer featLayer, string fieldName, IColorRamp colorRamp, int count)
{
//值分级
IBasicHistogram pBasicHis = new BasicTableHistogramClass();
ITableHistogram pTabHis = (ITableHistogram)pBasicHis;
//贫困发生率
IClassifyGEN pClassify = new EqualIntervalClass();
pTabHis.Field = fieldName;
//IGeoFeatureLayer geolayer = (IGeoFeatureLayer)Layer;
ILayer Layer = (ILayer)featLayer;
ITable pTab = (ITable)Layer;
pTabHis.Table = pTab;
object doubleArrVal, longArrFreq;
pBasicHis.GetHistogram(out doubleArrVal, out longArrFreq); int nDes = count;
pClassify.Classify(doubleArrVal, longArrFreq, ref nDes);
object classes = pClassify.ClassBreaks;
double[] ClassNum;
ClassNum = (double[])pClassify.ClassBreaks;
int ClassCountResult = ClassNum.GetUpperBound(0);
IClassBreaksRenderer pRender = new ClassBreaksRendererClass();
pRender.BreakCount = ClassCountResult;
pRender.Field = fieldName;
ISimpleFillSymbol pSym;
IColor pColor;
for (int j = 0; j < ClassCountResult; j++)
{
pColor = colorRamp.get_Color(j * (colorRamp.Size-1) / (ClassCountResult-1));
pSym = new SimpleFillSymbolClass();
pSym.Color = pColor;
pRender.set_Symbol(j, (ISymbol)pSym);
pRender.set_Break(j, ClassNum[j + 1]);
pRender.set_Label(j, ClassNum[j].ToString("0.00") + " - " + ClassNum[j + 1].ToString("0.00"));
} IGeoFeatureLayer pGeoLyr = (IGeoFeatureLayer)Layer;
pGeoLyr.Renderer = (IFeatureRenderer)pRender;
} public void ProportionalRenderer(IFeatureLayer featLayer, string fieldName, IColorRamp colorRamp, double count)
{
IProportionalSymbolRenderer psrender = new ProportionalSymbolRendererClass();
psrender.Field = fieldName;
psrender.ValueUnit = esriUnits.esriUnknownUnits;
psrender.ValueRepresentation = esriValueRepresentations.esriValueRepUnknown;
//选择渲染的样式,与颜色 minsymbol为比填内容,否则没有效果
ISimpleMarkerSymbol markersym = new SimpleMarkerSymbol();
markersym.Size = count;
markersym.Style = esriSimpleMarkerStyle.esriSMSCircle;
markersym.Color = colorRamp.get_Color(127);
psrender.MinSymbol = markersym as ISymbol;
//IFeatureLayer featLayer = featLayer;
IGeoFeatureLayer geofeat = featLayer as IGeoFeatureLayer;
ICursor cursor = ((ITable)featLayer).Search(null, true);
IDataStatistics datastat = new DataStatisticsClass();
datastat.Cursor = cursor;
datastat.Field = fieldName;//千万不能忽视
IStatisticsResults statisticsResult;
try
{
statisticsResult = datastat.Statistics;
psrender.MinDataValue = statisticsResult.Minimum + 0.1;
psrender.MaxDataValue = statisticsResult.Maximum;
}
catch
{
MessageBox.Show("错误,选择的属性不是数值型!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
////设置background的样式
IFillSymbol fillsym = new SimpleFillSymbolClass();
fillsym.Color = getcolor(201, 201, 251);
ILineSymbol linesym = new SimpleLineSymbolClass();
linesym.Width = 1;
fillsym.Outline = linesym;
psrender.BackgroundSymbol = fillsym;
psrender.LegendSymbolCount = 6;//legend的数量
psrender.CreateLegendSymbols();//创建TOC的legend
geofeat.Renderer = (IFeatureRenderer)psrender;
}
按 Ctrl+C 复制代码
完整源码下载:FeatureAndRasterRenderer.rar
ArcEngine栅格和矢量渲染(含可视化颜色带)的更多相关文章
- CAD/DWG图Web网页可视化技术之栅格和矢量瓦片
背景 在上一篇博文中CAD图DWG解析WebGIS可视化技术分析总结提到,实现CAD/DWG图形Web展示的思路一般为解析AutoCAD图形格式,然后转成html5所能绘制的格式如svg,geojso ...
- AE 栅格图分级渲染
ArcEngine对矢量数据进行风格化实在是得心应手,同样的对于栅格图像也能进行风格化!以前没接触过,今天正好需要,做出了栅格图像的渲染!下面实现的思路: 1.定义渲染的一系列接口 2.判断图像是否建 ...
- Hive环境的安装部署(完美安装)(集群内或集群外都适用)(含卸载自带mysql安装指定版本)
Hive环境的安装部署(完美安装)(集群内或集群外都适用)(含卸载自带mysql安装指定版本) Hive 安装依赖 Hadoop 的集群,它是运行在 Hadoop 的基础上. 所以在安装 Hive 之 ...
- BitBlt()函数实现带数字百分比进度条控件、静态文本(STATIC)控件实现的位图进度条、自定义进度条控件实现七彩虹颜色带数字百分比
Windows API BitBlt()函数实现带数字百分比进度条控件. 有两个例子:一用定时器实现,二用多线程实现. 带有详细注解. 此例是本人原创,绝对是网上稀缺资源(本源码用Windows AP ...
- (七)WebGIS中栅格、矢量图层设计之栅格、矢量图层的本质
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.何为栅格数据,何为矢量数据? 在GIS中,对于数据格式的分类,我们 ...
- Android 颜色渲染(三) Shader颜色渲染
版权声明:本文为博主原创文章,未经博主允许不得转载. 相信看过在上一篇中提到的三篇文章后,大家已经对颜色处理方面有更深的体会. 之前讲到颜色渐变的效果, 具体怎么做呢,这就需要应用颜色渲染. 首先要介 ...
- iOS之tabbar图片去除渲染以及字体颜色统一配置
转发:http://www.cnblogs.com/qianLL/p/5521228.html 方式一 代码实现 这种要写很多代码 ,每个控制器都要写 UIImage *image=[UII ...
- OpenGL编程(一)渲染一个指定颜色的背景窗口
上次已经搭好了OpenGL编程的环境.已经成功运行了第一个程序.可只是照搬书上的代码,并没弄懂其中的原理.这次通过一个小程序来解释使用GLUT库编写OpenGL程序的过程. 程序的入口 与其他程序一样 ...
- Matplotlib:可视化颜色命名分类和映射颜色分类
Matplotlib中支持的所有颜色分类 映射颜色分类
随机推荐
- 贝叶斯网络基础(Probabilistic Graphical Models)
本篇博客是Daphne Koller课程Probabilistic Graphical Models(PGM)的学习笔记. 概率图模型是一类用图形模式表达基于概率相关关系的模型的总称.概率图模型共分为 ...
- PHP zip压缩文件及解压
PHP zip压缩文件及解压 利用ZipArchive 类实现 只有有函数.界面大家自己写 ZipArchive(PHP 5.3 + 已自带不需要安装dll) /** * 文件解压 * @param ...
- Django模板-模板标签
接着Django模板-基础知识继续写模板相关知识. if标签 {% if %} 标签接受 and , or 或者 not 关键字来对多个变量做判断 ,或者对变量取反( not ). 但是不允许在同一个 ...
- HTML5新属性
1.contenteditable 属性指定元素内容是否可编辑. 注意: 当元素中没有设置 contenteditable 属性时,元素将从父元素继承. 所有主流浏览器都支持 contentedita ...
- MYSQL设置字段数据过长自动截断
自动截断如下设置: windows: 修改my.ini: [mysqld] sql-mode="STRICT_TRANS_TABLES" linux: 修改/ect/mysql/m ...
- 16-GDBT(MART) 迭代决策树入门教程 | 简介
转载:http://blog.csdn.net/w28971023/article/details/8240756 GBDT(Gradient Boosting Decision Tree) 又叫 M ...
- Spring注释(转)
转自:http://www.ibm.com/developerworks/cn/java/j-lo-spring25-ioc/#ibm-pcon 概述 注释配置相对于 XML 配置具有很多的优势: 它 ...
- Delphi多线程数据库查询(ADO)
ADO多线程数据库查询通常会出现3个问题: 1.CoInitialize 没有调用(CoInitialize was not called):所以,在使用任何dbGo对象前,必须手 调用CoIniti ...
- Recover a file when you use git reset head by mistake.
$ git init Initialized empty Git repository in .git/ $ echo "testing reset" > file1 $ g ...
- java reflection总结
一.java反射常用方法 获取Class的几种方式: Class class1 = String.class;// 该方法最为安全可靠,程序性能更高. Class class2 = s ...