pumskins

Feature Layer (with definition layer) input in Kernel Density (Spatial Analyst)

Discussion created by pumskins on Dec 22, 2011
Latest reply on May 16, 2012 by ariharan3
Code below is the code I use to automate the kernel density functionality of spatial analyst. The input is a point feature layer. It works perfectly in my point layer input.

my point layer used in this code is    

pInputDataset = pFLayer.FeatureClass    

as input dataset in

  Dim pOutputDataset As IGeoDataset
            pOutputDataset = pDensityOp.KernelDensity(pInputDataset, 200))


Before this code is executed, I set a definition query set in my Point Layer used as input in my Kernel density, but still the output raster include all the points. I want only the points included in my definition query will be the input feature layer in my kernel density. Hope you can help me figure it out. Any idea on how to do it is appreciated.

Thanks very much









           Dim pMxDoc As IMxDocument = TryCast(m_application.Document, IMxDocument)

            Dim pMap As IMap = pMxDoc.FocusMap
            Dim pEnumLayer As IEnumLayer = pMap.Layers
            Dim pLayer As ILayer = pEnumLayer.Next
            Dim pFLayer As IFeatureLayer = Nothing
            Dim pActiveView As IActiveView = pMap
            Dim pInputDataset As IGeoDataset

            Do Until pLayer Is Nothing
                If pLayer.Name = "Target Layer" Then
                    pFLayer = pLayer
                    Exit Do
                End If
                pLayer = pEnumLayer.Next
            Loop


            Dim pDensityOp As IDensityOp
            pDensityOp = New RasterDensityOp




'need help in this part i think
'------------------------------------------------------
            pInputDataset = pFLayer.FeatureClass            

            'Create Raster Analysis Environment
            Dim pEnv As IRasterAnalysisEnvironment
            pEnv = pDensityOp

            'set output cell size
            pEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, 10)

            Dim pOutputDataset As IGeoDataset
            pOutputDataset = pDensityOp.KernelDensity(pInputDataset, 200))
'------------------------------------------------------

Outcomes