使用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. codevs1145

    题目描述                     Description 给定A.B.C三根足够长的细柱,在A柱上放有2n个中间有孔的圆盘,共有n个不同的尺寸,每个尺寸都有两个相同的圆盘,注意这两个圆 ...

  2. Android WebView 小结

    1.设置网页的缩放比例的时候,可以使用以下属性: mWebview.setInitialScale(25);//为25%,最小缩放等级 WebSettings setting = mWebview.g ...

  3. JavaScript基本概念(变量和数据类型)

    1. 变量 在局部作用域中省略var操作符可以定义全局变量,但是这么做会导致该变量难以维护,且在严格模式下会导致抛出ReferenceError错误. 2. 数据类型(js共用6种数据类型,分别是 U ...

  4. 星际争霸反作弊AG对战平台_支持108,113

    星际争霸反作弊AG对战平台_支持108,113,116 强大的星际反作弊功能,对战神器,让玩家公平对战 目前腾讯对战,浩方对战,VS对战平台都有星际外挂,AG平台什么都不干专门反外挂,希望热爱星际的玩 ...

  5. linux dd命令

    dd 是 Linux/UNIX 下的一个非常有用的命令,作用是用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换. 1. 命令简介 dd 的主要选项: 指定数字的地方若以下列字符结尾乘以相应的数 ...

  6. jQuery代码不能执行,必须在代码之前就要包含jQuery包

    <script>    $(function () {        $("#btnRegister").click(function () {            ...

  7. 如何利用多核CPU来加速你的Linux命令 — awk, sed, bzip2, grep, wc等

    http://blog.chinaunix.net/uid-20662820-id-4023733.html http://www.faqs.org/faqs/snmp-faq/part2/ http ...

  8. java的几个版本以及jre,jdk等概念——【转载】JDK、Java SE、Java EE、Java ME我该选

    我们平时使用的一些软件,有一部分需要Java环境的支持,但是SUN那么多的产品,让人眼花缭乱的版本号,前看后看都差不多的缩写,让我们选择起来的时候常常望而却步,只好跟着感觉走.所以下面我要介绍的就是那 ...

  9. 网易云课堂_程序设计入门-C语言_第三周:循环_1奇偶个数

    1 奇偶个数(5分) 题目内容: 你的程序要读入一系列正整数数据,输入-1表示输入结束,-1本身不是输入的数据.程序输出读到的数据中的奇数和偶数的个数. 输入格式: 一系列正整数,整数的范围是(0,1 ...

  10. scp的使用

    scp有两种版本 一种是ma的 直接使用scp命令 一种是winscp类似ftp mac版的scp命令格式如下: scp ./xxx.tar.gz root@ip: /root/xxx 这句话的意思是 ...