• 线密度和点密度计算


    与之前的欧式距离计算相似,这里算得是线密度和点密度,凡是桌面版ArcToolBox里的工具都可以用Geoprocessor这样的方式实现,真后悔没早点用9.2,在9.1里要进行这些运算麻烦多了。

    Public Function Density(ByVal SourceFeatureClass As IFeatureClass, ByVal ExtentFeatureClass As IFeatureClass, ByVal DensityRaster_SavePath As String, ByVal DensityRaster_SaveName As String, ByVal Radius As Double, ByVal CellSize As Integer, ByVal FieldName As String) As IRaster

            '得到矢量数据的范围
            Dim pEnv As IEnvelope
            pEnv = RasterHelper.GetFeatureClassEnvelop(ExtentFeatureClass)

            '通过FeatureClass得到矢量数据的路径
            Dim SourceDataPathName As String
            SourceDataPathName = GetPathFromFeatureClass(SourceFeatureClass)

            '设置运算的环境变量
            Dim str As String = pEnv.XMin & " " & pEnv.YMax & " " & pEnv.XMax & " " & pEnv.YMin

            Dim GeoPro As New ESRI.ArcGIS.Geoprocessor.Geoprocessor
            GeoPro.SetEnvironmentValue("extent", str)

            '分线密度和点密度两种方式进行运算
            Dim result As IGeoProcessorResult
            If SourceFeatureClass.ShapeType = esriGeometryType.esriGeometryPolyline Then
                '线密度

                Dim LDensity As LineDensity
                LDensity = New LineDensity

                '设置线密度运算器的属性
                With LDensity
                    .cell_size = CellSize
                    .in_polyline_features = SourceDataPathName
                    .out_raster = DensityRaster_SavePath & DensityRaster_SaveName & ".img"
                    .population_field = FieldName
                    .search_radius = Radius
                End With

                '进行线密度计算,得到结果
                result = GeoPro.Execute(LDensity, Nothing)

            ElseIf SourceFeatureClass.ShapeType = esriGeometryType.esriGeometryPoint Then
                '点密度

                Dim PDensity As PointDensity
                PDensity = New PointDensity

                '设置点密度运算器的属性
                With PDensity
                    .cell_size = CellSize
                    .in_point_features = SourceDataPathName
                    .neighborhood = Radius
                    .out_raster = DensityRaster_SavePath & DensityRaster_SaveName & ".img"
                    .population_field = FieldName
                End With

                '进行点密度计算,得到结果
                result = GeoPro.Execute(PDensity, Nothing)

            Else
                result = Nothing
                MessageBox.Show("文件出错")
            End If

            '得到输出结果数据的路径
            Dim RasterFullpath As String
            RasterFullpath = DensityRaster_SavePath & DensityRaster_SaveName & ".img"

            '通过结果数据路径得到RasterDataset
            Dim pRasterDataset As IRasterDataset
            pRasterDataset = GetRasterDatasetFromSourceData(RasterFullpath)

            '通过RasterDataset得到Raster
            Dim pRaster As IRaster
            pRaster = GetRasterFromRasterDataset(pRasterDataset)

            Return pRaster

        End Function

  • 相关阅读:
    angular2.0学习笔记4.npm常用指令记录及angular语法
    angular2.0学习笔记7.echarts 地图(type:'map')slice undifined 出错问题
    angular2.0学习笔记6.编程风格指南
    ionic3搭建笔记及编译成apk
    Ionic3--数据存储
    webpack入门笔记
    angular2.0学习笔记3.了解angular2.0项目结构
    angular2.0学习笔记2.创建hello world项目
    UVA 10954 Add All
    POJ 3069 Saruman's Army
  • 原文地址:https://www.cnblogs.com/luspa/p/1263881.html
Copyright © 2020-2023  润新知