示例代码: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)的更多相关文章
-
Arcgis engine 指定图层对要素进行创建、删除等操作
Arcgis engine 指定图层创建点要素 在指定的图层上创建一个点要素,点要素的位置是通过X,Y坐标指定的,下面是具体的注释 .其中 和IFeatureClassWrite接口有关的代码不要好像 ...
-
ArcEngine查询、添加、删除要素的方法
原文 ArcEngine查询.添加.删除要素的方法 1.查找数据 1).利用FeaturCursor进行空间查询 //空间查询 ISpatialFilter spatialFilter = new S ...
-
Geodatabase - 删除要素
//删除要素类. //例如:workspacePath=@"G:\doc\gis\1.400\data\pdb.mdb", featureClassPath="res2_ ...
-
如何删除要素类 IFeatureWorkspace 接口介绍(1)
如何删除要素类 要想删除一个要素类,那么必须先得到这个,在得到这个要素类的时候,我们要学习一个新的接口IFeatureWorkspace. IFeatureWorkspace 接口介绍 这个接口主要 ...
-
openlayers2地图控件扩展:要素删除DeleteFeature
实现要素删除控件,扩展OpenLayers.Control类,实现效果:选择DeleteFeature工具后,选择要素,按delete键删除要素(这里的删除只是将feature设置成delete状态, ...
-
ArcGIS Engine中删除要素的几种方法总结
转自原文 ArcGIS Engine中删除要素的几种方法总结 /// <summary> /// 通过IFeature.Delete方法删除要素 /// </summary> ...
-
Three.js开发指南---创建,加载高级网格和几何体(第八章)
本章的主要内容: 一, 通过Three.js自带的功能来组合和合并已有的几何体,创建出新的几何体 二, 从外部资源中加载网格和几何体 1 前面的章节中,我们学习到,一个几何体创建的网格,想使用多个材质 ...
-
基于ArcGIS ModelBuilder的GDB批量分区裁剪——可保留原始GDB要素集要素类结构
文章版权由作者pxtgis和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/pxtgis/. 一.概述 在数据处理工作中经常遇到批量裁剪ArcGIS文件地理数据库( ...
-
各种隐藏 WebShell、创建、删除畸形目录、特殊文件名、黑帽SEO作弊(转自核大大)
其实这个问题,经常有朋友问我,我也都帮大家解决了…… 但是现在这些现象越来越严重,而且手法毒辣.隐蔽.变态,清除了又来了,删掉了又恢复了,最后直接找不到文件了,但是访问网站还在,急的各大管理员.站长抓 ...
随机推荐
-
wpf读取mysql字段类型为text的问题
在读取数据库中的字段时,可能会根据环境的不同导致一些字段的读取方式不尽相同,在sql数据库中读取字段值用的最多的算是dataTable.Rows[行][列],但是到了mysql中就会有一些差别,在fl ...
-
理解jar
对于大多数 Java 开发人员来说,JAR 文件及其 “近亲” WAR 和 EAR 都只不过是漫长的 Ant 或 Maven 流程的最终结果.标准步骤是将一个 JAR 复制到服务器(或者,少数情况下是 ...
-
Windows 位图
目录 第1章简介 1 1.1 DFB 1 1.2 DDB 1 1.3 DIB 2 第2章相关API 3 2.1 创建 3 2.1.1 CreateCompatibl ...
-
Bean实例化(Spring源码阅读)-我们到底能走多远系列(33)
我们到底能走多远系列(33) 扯淡: 各位: 命运就算颠沛流离 命运就算曲折离奇 命运就算恐吓着你做人没趣味 别流泪 心酸 更不应舍弃 ... 主题: Spring源码阅读还在继 ...
-
Vue 进阶之路(九)
之前的文章我们介绍了 vue 中父组件之间的传值,本章我们再来看一下父子组件间传值的参数校验和非 Props 特性. <!DOCTYPE html> <html lang=" ...
-
【C++】类前置声明范例
• 在编写C++程序的时候,偶尔需要用到前置声明(Forward declaration).下面的程序中,带注释的那行就是类B的前置说明.这是必须的,因为类A中用到了类B,而类B的声明出现在类A的后面 ...
-
openstack之flavor管理
概览 [root@cc07 ~]# nova help | grep flavor flavor-access-add Add flavor access for the given tenant. ...
-
类的静态(Static)成员——字段
定义一个雇员类: namespace StaticFieldTest1 { class Employee { public int Id { get; set; } public string Fir ...
-
iOS:位置相关(18-03-09更)
1.定位设置 2.定位页面逻辑 1.定位设置 2.定位页面逻辑 1).第一次进入该VC,在 viewDidLoad 调用刷新页面 refreshLocationView .这时用户还没决定,会刷出“正 ...
- 本书版权输出到*地区,《深入理解Android内核设计思想》诚挚感谢大家一直以来的支持!