zoukankan      html  css  js  c++  java
  • 对矢量数据进行欧式距离计算

    欧式距离计算,采用SpatialAnalystTools中的EucDistance ,比较方便,其中GetFeatureClassEnvelop,GetPathFromFeatureClass,GetRasterDatasetFromSourceData,GetRasterFromRasterDataset是另外写的函数(这几个函数写的很搞笑,就是些RasterDataset、Raster和FeatureClass、shp之间的关系及转换,其实可以不用这么写的,高手要是见了,估计会狂鄙视我的,呵呵)。

    Public Function Eucdistance(ByVal SourceFeatureClass As IFeatureClass, ByVal ExtentFeatureClass As IFeatureClass, ByVal MaxDistance As Integer, ByVal EuclideanRaster_SavePath As String, ByVal EuclideanRaster_SaveName As String, ByVal CellSize As Integer) As IRaster

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

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

            '设置欧式距离计算器的参数
            Dim Eucdist As EucDistance = New EucDistance()
            With Eucdist
                .cell_size = CellSize
                .maximum_distance = MaxDistance
                .in_source_data = SourceDataPathName
                .out_distance_raster = EuclideanRaster_SavePath & EuclideanRaster_SaveName & ".img"
            End With

            '设置运算的环境变量
            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
            result = GeoPro.Execute(Eucdist, Nothing)

            '得到结果数据的路径
            Dim RasterFullpath As String
            RasterFullpath = Eucdist.out_distance_raster

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

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

            Return pRaster

        End Function

  • 相关阅读:
    GNU编码标准
    glade2 与 glade 3 (转)
    简单 gcc 参数
    gtk 主循环函数
    指针与数组关联导致的一些现象
    C语言声明数组变量时,在什么情况下,可不指定数组大小
    文件复制函数的效率比较
    关于VMware虚拟机的上网
    errno的基本用法
    查找数组中最大的2个数
  • 原文地址:https://www.cnblogs.com/luspa/p/1263876.html
Copyright © 2011-2022 走看看