示例代码: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. 根据IP定位用户所在城市信息

    http://www.9958.pw/post/city_ip 1.调用新浪IP地址库 新浪提供了开放的IP地址库数据供开发者调用,调用地址: http://int.dpool.sina.com.cn ...

  2. python起个简单web服务器

    在 Linux 服务器上或安装了 Python 的机器上,Python自带了一个WEB服务器 SimpleHTTPServer. 我们可以很简单的使用  python -m SimpleHTTPSer ...

  3. laravel5.*安装使用Redis以及解决Class 'Predis\Client' not found和Fatal error: Non-static method Redis::set() cannot be called statically错误

    https://phpartisan.cn/news/35.html laravel中我们可以很简单的使用Redis,如何在服务器安装Redis以及原创访问你们可以访问Ubuntu 设置Redis密码 ...

  4. uni-app学习记录04-轮播图和滑屏图片

    <template> <view> <!-- 轮播图视图 swiper-item是每页的元素 --> <swiper :indicator-dots=&quo ...

  5. H3C 调试OSPF

  6. 关于Spring JavaWeb工程中的ContextRefreshedEvent事件

    在应用启动时,通常想在此时预加载一些资源,全局使用. Spring会在操作应用上下文时,使用ApplicationEventPublisher触发相关ApplicationContextEvent,我 ...

  7. P1044 最大值最小化

    题目描述 在印刷术发明之前,复制一本书是一个很困难的工作,工作量很大,而且需要大家的积极配合来抄写一本书,团队合作能力很重要.当时都是通过招募抄写员来进行书本的录入和复制工作的, 假设现在要抄写 \( ...

  8. C# 性能分析 反射 VS 配置文件 VS 预编译

    本文分析在 C# 中使用反射和配置文件和预编译做注入的性能,本文的数据是为预编译框架,开发高性能应用 - 课程 - 微软技术暨生态大会 2018 - walterlv提供 本文通过代码生成工具,使用C ...

  9. codeforces 1185G1 状压dp

    codeforces 1185G1. Playlist for Polycarp (easy version)(动态规划) 传送门:https://codeforces.com/contest/118 ...

  10. poj/OpenJ_Bailian - 2528 离散化+线段树

    传送门:http://bailian.openjudge.cn/practice/2528?lang=en_US //http://poj.org/problem?id=2528 题意: 给你n长海报 ...