使用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栅格和矢量渲染(含可视化颜色带)的更多相关文章

  1. CAD/DWG图Web网页可视化技术之栅格和矢量瓦片

    背景 在上一篇博文中CAD图DWG解析WebGIS可视化技术分析总结提到,实现CAD/DWG图形Web展示的思路一般为解析AutoCAD图形格式,然后转成html5所能绘制的格式如svg,geojso ...

  2. AE 栅格图分级渲染

    ArcEngine对矢量数据进行风格化实在是得心应手,同样的对于栅格图像也能进行风格化!以前没接触过,今天正好需要,做出了栅格图像的渲染!下面实现的思路: 1.定义渲染的一系列接口 2.判断图像是否建 ...

  3. Hive环境的安装部署(完美安装)(集群内或集群外都适用)(含卸载自带mysql安装指定版本)

    Hive环境的安装部署(完美安装)(集群内或集群外都适用)(含卸载自带mysql安装指定版本) Hive 安装依赖 Hadoop 的集群,它是运行在 Hadoop 的基础上. 所以在安装 Hive 之 ...

  4. BitBlt()函数实现带数字百分比进度条控件、静态文本(STATIC)控件实现的位图进度条、自定义进度条控件实现七彩虹颜色带数字百分比

    Windows API BitBlt()函数实现带数字百分比进度条控件. 有两个例子:一用定时器实现,二用多线程实现. 带有详细注解. 此例是本人原创,绝对是网上稀缺资源(本源码用Windows AP ...

  5. (七)WebGIS中栅格、矢量图层设计之栅格、矢量图层的本质

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.何为栅格数据,何为矢量数据? 在GIS中,对于数据格式的分类,我们 ...

  6. Android 颜色渲染(三) Shader颜色渲染

    版权声明:本文为博主原创文章,未经博主允许不得转载. 相信看过在上一篇中提到的三篇文章后,大家已经对颜色处理方面有更深的体会. 之前讲到颜色渐变的效果, 具体怎么做呢,这就需要应用颜色渲染. 首先要介 ...

  7. iOS之tabbar图片去除渲染以及字体颜色统一配置

    转发:http://www.cnblogs.com/qianLL/p/5521228.html   方式一  代码实现 这种要写很多代码 ,每个控制器都要写   UIImage *image=[UII ...

  8. OpenGL编程(一)渲染一个指定颜色的背景窗口

    上次已经搭好了OpenGL编程的环境.已经成功运行了第一个程序.可只是照搬书上的代码,并没弄懂其中的原理.这次通过一个小程序来解释使用GLUT库编写OpenGL程序的过程. 程序的入口 与其他程序一样 ...

  9. Matplotlib:可视化颜色命名分类和映射颜色分类

    Matplotlib中支持的所有颜色分类 映射颜色分类

随机推荐

  1. c++ :OOP之静态类型与动态类型

    所谓静态类型即类型指针或引用的字面类型:而动态类型即类型指针或引用的实际类型. 这一对概念一般发生在基类和派生类之间. 如: class Base { ..... } class Derived : ...

  2. MySQL如何使用索引 较为详细的分析和例子

    在数据库表中,使用索引可以大大提高查询速度. 假如我们创建了一个 testIndex 表: CREATE TABLE testIndex(i_testID INT NOT NULL,vc_Name V ...

  3. mysql学习(七)-索引学习

    常规索引: 在常用查询的字段上使用常规索引 创建表时一块创建索引 create table if not exists carshop(id int not null auto_increment, ...

  4. 表单提交中get与post的区别

    在Form里面,可以使用post也可以使用get.它们都是method的合法取值. 1. get是从服务器上获取数据,post是向服务器传送数据.   2. get是把参数数据队列加到提交表单的ACT ...

  5. sqlmap新手注入

    一 什么是sqlmap sqlmap is an open source penetration testing tool that automates the process of detectin ...

  6. Diet

    Dialogue 1   Healthy diet 关于健康饮食 F:Bob, look at this sentence. 'Healthy eating is not about strict n ...

  7. web 之MVC

    MVC 把一个应用的输入.处理.输出流程按照Model, View, Controller 的方式进行分离,这样一个应用被分为三层:模型层.视图层.控制层. 1.View 2.Controller 在 ...

  8. "创业"半年

                作为一个程序员, 因为受够了”给别人实现梦想太累”的念头, 又受到”外面给出更高薪水”的诱惑, 果断离职创业. 但原本是要创业的, 过了半年, 变成了失业, 这其中到底经历了哪 ...

  9. 安卓使用spinner控件和pull解析实现全国省市县的三级联动

    实现该功能主要有两个难点: 1.XML文件的Pull解析.由于XML文件的结构较为复杂,所以解析时要注意,划分XML文件的结构,根据结构建立相应的和集合.本例中需要建立三个类和三个对象.三个类分别为, ...

  10. 常用在线工具及API网址总结

    1.小图标在线查找 https://www.iconfinder.com/ 2.在线做图,Flowchart流程图,BPMN图,Org组织结构图等 http://www.processon.com/ ...