Creating Theissen Polygons in ArcMap

Import from my old blog

Public Function CreateThiessenFC(pFeatureClass As IFeatureClass, pPoly As IPolygon, pFDS As IFeatureDataset) As IFeatureClass 'If (Not dbUtil.ResolveOutputFeatureClassName(txtOutput, sOutCat, sOutWSName, sOutDSName, sOutFCName, True)) Then ' If (dbUtil.GetErrorCode = 1) Then ' MsgBox dbUtil.GetErrorMessage, vbCritical ' End If ' Exit Sub 'End If 'Me.MousePointer = vbHourglass  Dim pGDS As IGeoDataset Set pGDS = pFeatureClass Dim pSR As ISpatialReference Set pSR = pGDS.SpatialReference  Dim pFields As IFields2 Set pFields = pFeatureClass.Fields  Dim pOIDField As IField Dim lOIDInx As Long lOIDInx = pFields.FindField(pFeatureClass.OIDFieldName) Set pOIDField = pFields.Field(lOIDInx)  Dim pOutFC As IFeatureClass 'Check the parameter of this function Set pOutFC = createDatasetFeatureClass(pFDS, "thiessen", esriFTSimple, esriGeometryPolygon, Nothing, Nothing, Nothing) 'This is the old one 'Set pOutFC = createDatasetFeatureClass(sOutCat, sOutWSName, sOutDSName, sOutFCName, esriGeometryPolygon, False, False, pSR)  Dim pTinEdit As ITinEdit Set pTinEdit = New Tin pTinEdit.InitNew pGDS.Extent  Dim pTinAdv As ITinAdvanced2 Set pTinAdv = pTinEdit  pTinEdit.AddFromFeatureClass pFeatureClass, Nothing, pOIDField, pOIDField, esriTinMassPoint  pTinEdit.Refresh ' get proper extent so default voronoi clip poly is ok   'Before converting to the theissen check for the bounding polygon   Dim pNodeCol As ITinNodeCollection Set pNodeCol = pTinEdit pNodeCol.ConvertToVoronoiRegions pOutFC, Nothing, pPoly, "", ""  'pTinEdit.SaveAs (sOutWSName & "\" & dbUtil.GetUniqueFileName(sOutWSName)) 'pTinEdit.StopEditing False  'AddFeatureLayer m_pApp, pOutFC  Set CreateThiessenFC = pOutFC  'Release the variables  Set pGDS = Nothing Set pSR = Nothing Set pFields = Nothing Set pOIDField = Nothing 'Set lOIDInx = Nothing Set pOutFC = Nothing Set pNodeCol = Nothing Set pNodeCol = Nothing  End Function