示例代码:https://github.com/yu969890202/ArcEngine/tree/master/WinFrom_ArcEngine_PointDistribution
博客后面有两张图片,不懂得可以看看效果 Public Function CreateFeatureClass() As IFeatureClass
Dim pWorkspaceFactory As IWorkspaceFactory = New ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactory
Dim dataset As IDataset = pPointFeatureLayer.FeatureClass
Dim featureWorkspace As IFeatureWorkspace = pWorkspaceFactory.OpenFromFile(dataset.Workspace.PathName, ) 'dataset.Workspace.PathName="C:\\aa.mdb"
Dim workspace As IWorkspace2 = featureWorkspace
Dim featureClassName As String = "New"
Dim fields As IFields = Nothing
Dim CLSID As ESRI.ArcGIS.esriSystem.UID = Nothing
Dim CLSEXT As ESRI.ArcGIS.esriSystem.UID = Nothing
Dim strConfigKeyword As String = ""
Dim featureClass As IFeatureClass
If workspace.NameExists(esriDatasetType.esriDTFeatureClass, featureClassName) Then '如果存在删除改要素
featureClass = featureWorkspace.OpenFeatureClass(featureClassName)
Dim pDataset As IDataset = featureClass
pDataset.Delete() '删除该要素
End If
' 赋值类ID如果未分配
If CLSID Is Nothing Then
CLSID = New ESRI.ArcGIS.esriSystem.UID
CLSID.Value = "esriGeoDatabase.Feature"
End If
Dim objectClassDescription As IObjectClassDescription = New FeatureClassDescription
If fields Is Nothing Then
' 创建字段
fields = objectClassDescription.RequiredFields
Dim fieldsEdit As IFieldsEdit = CType(fields, IFieldsEdit)
Dim field As IField = New Field
Dim fieldEdit As IFieldEdit = CType(field, IFieldEdit) ' 显示转换
' 设置字段属性
fieldEdit.Name_2 = "SampleField"
fieldEdit.Type_2 = esriFieldType.esriFieldTypeString
fieldEdit.IsNullable_2 = True
fieldEdit.AliasName_2 = "Sample Field Column"
fieldEdit.DefaultValue_2 = "test"
fieldEdit.Editable_2 = True
fieldEdit.Length_2 =
'添加到字段集中
fieldsEdit.AddField(field)
fields = CType(fieldsEdit, IFields)
End If
Dim strShapeField As String = ""
Dim j As Int32
For j = To fields.FieldCount
If fields.Field(j).Type = esriFieldType.esriFieldTypeGeometry Then
strShapeField = fields.Field(j).Name
Exit For
End If
Next j
Dim fieldChecker As IFieldChecker = New FieldChecker
Dim enumFieldError As IEnumFieldError = Nothing
Dim validatedFields As IFields = Nothing
fieldChecker.ValidateWorkspace = CType(workspace, IWorkspace)
fieldChecker.Validate(fields, enumFieldError, validatedFields)
featureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, CLSID, CLSEXT, esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword) '添加要素,跟据其他要素的范围,生成一个边长为length的矩形网格用于渲染
Dim length As Integer = '方块长度
Dim pLineLayer As ILayer = pLineFeatureLayer
Dim pEnvelope As IEnvelope = pLineLayer.AreaOfInterest
Dim XMin As Double = pEnvelope.XMin
Dim XMax As Double = pEnvelope.XMax Dim YMax As Double = pEnvelope.YMax
Dim newXMin As Double = XMin + length Do While newXMin < XMax
Dim YMin As Double = pEnvelope.YMin
Dim newYMin As Double = YMin + length
Do While newYMin < YMax
AddFeature(XMin, newXMin, YMin, newYMin, featureClass.CreateFeature())
YMin = newYMin
newYMin = YMin + length
Loop
AddFeature(XMin, newXMin, YMin, newYMin, featureClass.CreateFeature())
XMin = newXMin
newXMin = XMin + length
Loop
Dim pNewFeatureLayer As IFeatureLayer = New FeatureLayer
pNewFeatureLayer.FeatureClass = featureClass
m_MapControl.AddLayer(pNewFeatureLayer, )
m_MapControl.Refresh()
MessageBox.Show("生成完毕")
End Function

创建单个方格要素:

    Private Function AddFeature(ByVal XMin As Double, ByVal newXMin As Double, ByVal YMin As Double, ByVal newYMin As Double, ByVal pFeature As IFeature)
Dim pPoint1 As IPoint = New Point()
pPoint1.X = XMin
pPoint1.Y = YMin
Dim pPoint2 As IPoint = New Point()
pPoint2.X = newXMin
pPoint2.Y = YMin
Dim pPoint3 As IPoint = New Point()
pPoint3.X = newXMin
pPoint3.Y = newYMin
Dim pPoint4 As IPoint = New Point()
pPoint4.X = XMin
pPoint4.Y = newYMin
Dim pPOlygon As IPolygon
Dim pPointColec As IPointCollection = New Polygon
pPointColec.AddPoint(pPoint1)
pPointColec.AddPoint(pPoint2)
pPointColec.AddPoint(pPoint3)
pPointColec.AddPoint(pPoint4)
pPOlygon = CType(pPointColec, IPolygon)
pFeature.Shape = pPOlygon
pFeature.Store()
End Function

生成(黄色格网为生成图层)后如下图:

后面开始添加值和渲染图层:

通过空间查询,再生成方格(Featuer)时通过空间查询查询方格上面点的个数。

  Dim pSpatialFilter As ESRI.ArcGIS.Geodatabase.ISpatialFilter = New ESRI.ArcGIS.Geodatabase.SpatialFilter
pSpatialFilter.Geometry = pPolygon
pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects '相交的状态
Dim featureCursor As ESRI.ArcGIS.Geodatabase.IFeatureCursor = pPointFeatureLayer.FeatureClass.Search(pSpatialFilter, False)
Dim count As Integer =
Dim pTmpFeature = featureCursor.NextFeature()
While Not IsNothing(pTmpFeature)
count +=
pTmpFeature = featureCursor.NextFeature()
End While
Dim fieldindex As Integer = pFeature.Fields.FindField("num")
pFeature.Value(fieldindex) = count

然后通过生成的字段进行渐变渲染:

  Private Sub DefineUniqueValueRenderer(ByVal pGeoFeatureLayer As IGeoFeatureLayer, ByVal fieldName As String)
'创建于渲染器的符号渐变颜色.
Dim algColorRamp As IAlgorithmicColorRamp = New AlgorithmicColorRamp
algColorRamp.FromColor = getRgbColor(, , ) '灰色
algColorRamp.ToColor = getRgbColor(, , )
algColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm
Dim pUniqueValueRenderer As IUniqueValueRenderer = New UniqueValueRenderer()
Dim pSimpleFillSymbol As ISimpleFillSymbol = New SimpleFillSymbol()
pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid
pSimpleFillSymbol.Outline.Width = 0.4 '这些属性之前应增加值来设置.
pUniqueValueRenderer.FieldCount =
pUniqueValueRenderer.Field() = fieldName
pUniqueValueRenderer.DefaultSymbol = pSimpleFillSymbol
pUniqueValueRenderer.UseDefaultSymbol = False '不使用空值的黑色样式
Dim pDisplayTable As IDisplayTable = pGeoFeatureLayer
Dim i As Integer =
Dim strsql As String = "SELECT distinct(num) FROM new order by num"
Dim pDR As IDataReader = Nothing
Try
pDR = DBHelper.Create().ExecuteReader(strsql)
While pDR.Read
'每一个值都要生成一个新的样式,如果只创建一个样式对象的话,最后生成的效果会是一样的。
Dim pClassSymbol As ISimpleFillSymbol = New SimpleFillSymbol()
pClassSymbol.Style = esriSimpleFillStyle.esriSFSSolid
pClassSymbol.Outline.Width = 0.4
Dim classValue As Integer = CType(pDR.GetValue(), Integer)
pUniqueValueRenderer.AddValue(classValue, fieldName, pClassSymbol)
pUniqueValueRenderer.Label(classValue) = classValue
pUniqueValueRenderer.Symbol(classValue) = pClassSymbol
i +=
End While
pDR.Close()
DBHelper.Create().CloseDBConnection()
Catch ex As Exception
If pDR IsNot Nothing Then pDR.Close()
DBHelper.Create().CloseDBConnection()
End Try
algColorRamp.Size = pUniqueValueRenderer.ValueCount
Dim bOK As Boolean
algColorRamp.CreateRamp(bOK)
Dim pEnumColors As IEnumColors = algColorRamp.Colors
pEnumColors.Reset()
Dim j As Integer
For j = To pUniqueValueRenderer.ValueCount - Step j +
Dim xv As String
xv = pUniqueValueRenderer.Value(j)
If xv <> "" Then
Dim pSimpleFillColor As ISimpleFillSymbol = pUniqueValueRenderer.Symbol(xv)
pSimpleFillColor.Color = pEnumColors.Next()
pUniqueValueRenderer.Symbol(xv) = pSimpleFillColor
End If Next
pUniqueValueRenderer.ColorScheme = "Custom"
pGeoFeatureLayer.Renderer = pUniqueValueRenderer
Dim pUID As IUID = New UID()
pUID.Value = "{683C994E-A17B-11D1-8816-080009EC732A}"
pGeoFeatureLayer.RendererPropertyPageClassID = pUID

获取Color:

 Private Function getRgbColor(ByVal r As Integer, ByVal g As Integer, ByVal b As Integer) As IColor
Dim pRgbColr As IRgbColor = New RgbColor
pRgbColr.Red = r
pRgbColr.Green = g
pRgbColr.Blue = b
Dim pColor As IColor = CType(pRgbColr, IColor)
Return pColor
End Function

生成后的效果如下图:

ArcEngine 创建要素,删除要素,生成网格,渲染图层(VB)的更多相关文章

  1. Arcgis engine 指定图层对要素进行创建、删除等操作

    Arcgis engine 指定图层创建点要素 在指定的图层上创建一个点要素,点要素的位置是通过X,Y坐标指定的,下面是具体的注释 .其中 和IFeatureClassWrite接口有关的代码不要好像 ...

  2. ArcEngine查询、添加、删除要素的方法

    原文 ArcEngine查询.添加.删除要素的方法 1.查找数据 1).利用FeaturCursor进行空间查询 //空间查询 ISpatialFilter spatialFilter = new S ...

  3. Geodatabase - 删除要素

    //删除要素类. //例如:workspacePath=@"G:\doc\gis\1.400\data\pdb.mdb", featureClassPath="res2_ ...

  4. 如何删除要素类 IFeatureWorkspace 接口介绍(1)

    如何删除要素类 要想删除一个要素类,那么必须先得到这个,在得到这个要素类的时候,我们要学习一个新的接口IFeatureWorkspace. IFeatureWorkspace  接口介绍 这个接口主要 ...

  5. openlayers2地图控件扩展:要素删除DeleteFeature

    实现要素删除控件,扩展OpenLayers.Control类,实现效果:选择DeleteFeature工具后,选择要素,按delete键删除要素(这里的删除只是将feature设置成delete状态, ...

  6. ArcGIS Engine中删除要素的几种方法总结

    转自原文 ArcGIS Engine中删除要素的几种方法总结 /// <summary> /// 通过IFeature.Delete方法删除要素 /// </summary> ...

  7. Three.js开发指南---创建,加载高级网格和几何体(第八章)

    本章的主要内容: 一, 通过Three.js自带的功能来组合和合并已有的几何体,创建出新的几何体 二, 从外部资源中加载网格和几何体 1 前面的章节中,我们学习到,一个几何体创建的网格,想使用多个材质 ...

  8. 基于ArcGIS ModelBuilder的GDB批量分区裁剪——可保留原始GDB要素集要素类结构

    文章版权由作者pxtgis和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/pxtgis/. 一.概述 在数据处理工作中经常遇到批量裁剪ArcGIS文件地理数据库( ...

  9. 各种隐藏 WebShell、创建、删除畸形目录、特殊文件名、黑帽SEO作弊(转自核大大)

    其实这个问题,经常有朋友问我,我也都帮大家解决了…… 但是现在这些现象越来越严重,而且手法毒辣.隐蔽.变态,清除了又来了,删掉了又恢复了,最后直接找不到文件了,但是访问网站还在,急的各大管理员.站长抓 ...

随机推荐

  1. vue用法父组件调用子组件方法--->$refs

    vue下载excel模板(放入弹框独立出来)后再导入表格 子组件 <el-dialog title="导入" :visible.sync="dialogVisibl ...

  2. jekyll 添加 Valine 评论

    本文告诉大家如何在自己搭建的静态博客添加 Valine 评论.在这前,我基本都是使用 多说,但是多说gg啦,所以就在找一个可以替换的评论 本来 Disqus是很好的,但是在国内很难打开,所以我就需要一 ...

  3. java异常处理格式

    异常处理的5个关键字 try ,catch, finally throw, throws   我的总结: 捕获异常:先捕获小异常再捕获大异常. 程序是调出来的,不是写出来的:多测试是程序员的必修课. ...

  4. Bishops Alliance—— 最大上升子序列

    原题链接:http://codeforces.com/gym/101147/problem/F 题意:n*n的棋盘,给m个主教的坐标及其私有距离p,以及常数C,求位于同一对角线上满足条件:dist(i ...

  5. ssh使用笔记

    在集群管理和配置中有很多命令要在各个节点中发送(特别是Master->Worker),大家都不希望发送每一个命令时都输入一次密码,因此常常先配置实现Master无密码登录到所有的Worker节点 ...

  6. P1035 台阶问题二

    题目描述 有 \(N\) 级的台阶,你一开始在底部,每次可以向上迈最多 \(K\) 级台阶(最少 \(1\) 级),问到达第 \(N\) 级台阶有多少种不同方式. 输入格式 两个正整数 \(N, K( ...

  7. 将url传参的中文字符在页面中显示正常

    //将url传参的中文字符在页面中显示正常var url=decodeURI(url);

  8. ASP.NET Core 开启后台任务

    本文告诉大家如何通过 Microsoft.Extensions.Hosting.BackgroundService 开启后台任务 实现 BackManagerService 类继承 Backgroun ...

  9. Spring Security 学习笔记-securityContext过滤器

    位于过滤器顶端,第一个起作用的过滤器.SecurityContextPersistenceFilter 在执行其他过滤器之前,率先判断用户的session中是否已经存在一个SecurityContex ...

  10. 基于JWT的Token登录认证(一)

    1.JWT简介 JSON Web Token(缩写 JWT),是目前最流行的跨域认证解决方案. session登录认证方案:用户从客户端传递用户名.密码等信息,服务端认证后将信息存储在session中 ...