21

I have a featureclass in an Esri file geodatabase. When I edit the features using the editor in ArcMap, and I delete most of my features and keeping only the ones in the middle, the zoom to layer command doesn't work as expected. Instead of zooming to the extent of the features remaining in the feature class, the extent will be the former one (containing all deleted features). When reviewing the extent values in the properties dialog for the feature class, I can clearly see the old values. So the edit session doesn't seem to alter the full extent values.

Is there a way to recalculate these values?

I am pretty sure that this problem should occur to everyone editing features in ArcMap...

1
  • 1
    Unfortunately Arc: REBOX did not get translated to as an ArcGIS tool :-)
    – PolyGeo
    Commented May 3, 2012 at 2:25

7 Answers 7

20

Right-click the feature class in ArcCatalog and go to the Properties. In the Feature Extent tab, click on Recalculate. And voilà!

I'm using ArcGIS 10.2.1

0
6

Esri now has a tool for this in 10.4 (hooray): Recalculate Feature Class Extent.

I was running into this issue when I was creating a feature class and writing geometry into it with arcpy. Apparently those tools do not update the extent (probably a good idea for performance reasons).

I have been successful resetting the extent in 10.2.2 with @Lou 's suggestion:

arcpy.CompressFileGeodatabaseData_management(output_workspace)
arcpy.UncompressFileGeodatabaseData_management(output_workspace)
6

Compacting the Geodatabase will tidy up your spatial index

"If you frequently add and delete data, you should compact your file or personal geodatabase on a monthly basis. You should also compact a geodatabase after any large-scale change. Compacting tidies up storage by reordering records and eliminating unused space. After compacting, the data in each file can be accessed more efficiently. Compacting also reduces the size of each file—it’s possible to be able to reduce the size of a geodatabase by one-half or more."

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Compacting_file_and_personal_geodatabases/003n0000007t000000/

Compact (Data Management)

"It is recommended to compact personal geodatabases when they become larger than 250 MB. If data entry, deletion, or general editing is frequently performed on a database, the database should be regularly compacted to ensure optimal performance."

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000000n000000

1
  • 4
    If you're doing massive deletes, this is an important thing to do (especially for larger geodatabases). I've personally not had it reliably fix the extent problem, but it's definitely a good idea.
    – Lou
    Commented May 2, 2012 at 15:42
6

Here is an ArcCatalog add-in for ArcGIS 10 that adds a command to update the feature class extent, likely using the same method as @Ragi's VBA code:

1
5

The GeoDatabase Extent always expands out - never shortens automatically. Compacting and Compressing only optimizes storage and fragmentation, but not the Extent itself. I would try recreating the spatial index first and see if that does the trick.

Update:

Since the spatial index rebuilding doesn't do the trick, I am sure the following VBA code will:

Public Sub reCalcExt()
  Dim pGXApplication As IGxApplication
  Set pGXApplication = Application

  Dim pGxObject As IGxObject
  Set pGxObject = pGXApplication.SelectedObject

  If Not TypeOf pGxObject.InternalObjectName Is IFeatureClassName Then
    Exit Sub
  End If

  Dim pName As IName
  Set pName = pGxObject.InternalObjectName
  Dim pSchemaLock As ISchemaLock
  Set pSchemaLock = pName.Open

  pSchemaLock.ChangeSchemaLock esriExclusiveSchemaLock
  Dim pFeatureClassManage As IFeatureClassManage
  Set pFeatureClassManage = pSchemaLock
  pFeatureClassManage.UpdateExtent

  Exit Sub

ErrHandler:
  pSchemaLock.ChangeSchemaLock esriSharedSchemaLock
End Sub

You can do this in any other ESRI supported programming language. The trick is to get a schemalock and to use the IFeatureClassManage::UpdateExtent method.

3
  • I tried recreating the spatial index on a sample dataset, and that didn't help in my test case. I was honestly surprised.
    – Lou
    Commented May 2, 2012 at 19:05
  • Updating my answer with some code then. Commented May 2, 2012 at 20:11
  • By this way, this is ArcCatalog VBA code. Commented May 2, 2012 at 22:33
4

I don't know exactly what causes it in File Geodatabases, but I am indeed able to replicate it and it is something I've faced before. The only way I was able to find out how to bypass it is to Compress the file geodatabase. That will fix the extent issue. You will need to Decompress it when you're done, because you can't edit a Compressed file geodatabase.

During an edit/ArcMap session when you're actually using the data, you can always select all | zoom to selected as a workaround. It's not great, but I've used it in my workflow until I got to a breaking point where I could do that compress/decompress trick.

Note, Compacting will not work (at least, not reliably). It will rebuild your indices, but I've found it unreliable for fixing extent issues. It's still something you should do from time to time. I just tried it again right now, and it didn't work on my sample dataset. YMMV.

1
  • You can also move feature classes to a new geodatabase/shapefile, but I highly doubt that's an acceptable answer. However, on the odd chance that's part of your workflow (packaging the data for delivery) it may work for you and not require extra steps.
    – Lou
    Commented May 2, 2012 at 14:58
3

If you want to update extent of feature classess in your mxd document this chunk of code might help you:

Dim pLayer As ILayer
        Dim pEnumLayer As IEnumLayer
        Dim pFeatureLayer As IFeatureLayer
        Dim pFeatureClass As IFeatureClass
        Dim pFeatureClassManage As IFeatureClassManage


        pEnumLayer = pMap.Layers
        pLayer = pEnumLayer.Next

        Do Until pLayer Is Nothing
            If TypeOf pLayer Is FeatureLayer Then
                pFeatureLayer = pLayer
                pFeatureClass = pFeatureLayer.FeatureClass
                pFeatureClassManage = pFeatureClass
                pFeatureClassManage.UpdateExtent()
            End If
            pLayer = pEnumLayer.Next
        Loop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.