HOW TO

Find features with null geometries in ArcMap

Last Published: April 25, 2020

Summary

Instructions provided describe how to find features with null geometries in ArcMap. The table window allows features to be created that have no geometry; that is, they have a null value for the Shape field.

Procedure

The Visual Basic for Applications (VBA) sample code below selects the features with null geometries.
  1. Add a feature class to ArcMap.
  2. Select the feature class in the Table of Contents.
  3. Create a new UIButtonControl.
    Note:
    For more information on creating a UIControl see the ArcGIS Desktop Help topic Creating custom commands with VBA and UI Controls.
  4. With the Customize dialog box open, right-click the UIButtonControl and select View Source.
  5. Paste the code into the UIButtonControl's Click event.
    Dim pMXd As IMxDocument
    Set pMXd = ThisDocument
    Dim pMap As IMap
    Set pMap = pMXd.FocusMap
    
    ' Make sure there is a selected layer in map
    If pMXd.SelectedItem Is Nothing Then
    	MsgBox "Must have a selected item in map"
    	Exit Sub
    End If
    
    If Not TypeOf pMXd.SelectedItem Is IFeatureLayer Then
    	MsgBox "The selected item must be a layer"
    	Exit Sub
    End If
    
    Dim pDispTab As IDisplayTable
    Set pDispTab = pMXd.SelectedItem
    
    ' create an empty selectionset and open a feature cursor
    Dim pFCursor As IFeatureCursor
    Dim pSelSet As ISelectionSet
    Dim pTable As ITable
    Dim pFeatCls As IFeatureClass
    Dim pFeat As IFeature
    Set pTable = pDispTab.DisplayTable
    Set pSelSet = pTable.Select(Nothing, esriSelectionTypeHybrid, _
    esriSelectionOptionEmpty, Nothing)
    Set pFeatCls = pTable
    Set pFCursor = pFeatCls.Search(Nothing, False)
    
    ' add all features that are not null to the selection set
    Set pFeat = pFCursor.NextFeature
    Do While (Not pFeat Is Nothing)
    	If Not pFeat.Shape Is Nothing Then
    		If pFeat.Shape.IsEmpty Then
    			If pFeat.HasOID Then
    				pSelSet.Add pFeat.OID
    			End If
    		End If
    
    	End If
    	Set pFeat = pFCursor.NextFeature
    Loop
    
    ' apply the selectionset to the layer
    Dim pActiveView As IActiveView
    Dim pFeatSel As IFeatureSelection
    Set pActiveView = pMap
    Set pFeatSel = pDispTab
    pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
    Set pFeatSel.SelectionSet = pSelSet
    pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
    
  6. Close the Visual Basic Editor and click the UIButtonControl to run the code.
  7. Right-click the feature class in the Table of Contents. Select Open Attribute Table to display the features that have null geometries.

Article ID:000003699

Software:
  • Legacy Products

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options