Select to view content in your preferred language

Recalculate Extent

11337
10
02-06-2013 09:44 PM
gismoe
by
Frequent Contributor
I want to recalculate the Extent of some feature classes. I found some vba, c# code but the job has to be done with python.
arcpy.Describe will show me the extent but there seems to by no way to set the extent.

Any ideas?
Tags (2)
0 Kudos
10 Replies
JakeSkinner
Esri Esteemed Contributor
Hi Ernst,

Do your feature classes reside in a File/Personal Geodatabase, or an SDE Geodatabase?  If they reside in an SDE geodatabase you can use the 'sdelayer -o alter' command to recalculate the extent.  Ex:

import os
os.system("sdelayer -o alter -l parcels,shape -E calc -i sde:sqlserver:serverA -D GIS -u vector -p vector")


The '-E calc' option will recalculate the extent based on all the features.  Or you can optionally specify it:

-E -75.17,39.88,-75.13,39.92
0 Kudos
gismoe
by
Frequent Contributor
Thank you. I will try this for me data in my ArcSDE.

But i have further data in File/Personal Geodatabases. Do you have code for this problem? i can't find any solution.
0 Kudos
NeilAyres
MVP Alum
I have noticed in the past, when using a feature class as a "template". ie Copy it, delete all the features out of it, when re-populate it with new stuff. The extent somehow still reflects the old stuff.
So, I would also love to know how to do this for F & P gdb's.
Cheers
Neil
0 Kudos
gismoe
by
Frequent Contributor
Ok, sdelayer -alter...... works pretty well. Thank you!

But now the next step is to recalculate the extent for feature classes in File/Personal Geodatabases.......
0 Kudos
FrédéricPRALLY
Esri Contributor

Hi Ernst,

You could also use this tool GP Update Extent FClass​.

Hope this help you,

Fred

0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Ernst,

At 10.1, there is a way to recalculate the extent through the properties of the feature class.  In the Catalog window > right-click on the feature class > Properties > Feature Extent tab. 

[ATTACH=CONFIG]21603[/ATTACH]

The only way I was able to find a way to do this using python is to execute the Feature Class to Feature Class tool.  So, what you could do is execute the following tools:

arcpy.FeatureClassToFeatureClass_conversion
arcpy.Delete_management (delete the original feature class)
arcpy.Rename_management (rename the copied feature class to the original name)
0 Kudos
gismoe
by
Frequent Contributor
Hi Jake,

the way:

arcpy.FeatureClassToFeatureClass_conversion
arcpy.Delete_management (delete the original feature class)
arcpy.Rename_management (rename the copied feature class to the original name) 


works pretty well.

I also tried

sdelayer -o alter -l parcels,shape -E calc -i sde:sqlserver:serverA -D GIS -u vector -p vector


on my sde data. I get the message "...successful" but when i load the data in ArcMap it seems that nothing happend to the extent. I will only see a small point that represents my whole data. So the extent is too big.

The data in the ArcSDE is versioned. May this cause a problem? Before i ran sdelayer i stopped all running services.
0 Kudos
JakeSkinner
Esri Esteemed Contributor
If the feature class is registered as versioned, you will need to reconcile the child versions and then perform a compress.  If you are running ArcGIS for Desktop 10.1  you can make a connection as an administrator > right-click on the database connection > Administration > Administer Geodatabase > Reconcile Order tab.  Right-click on each version > Reconcile.  After each version is reconciled and no locks exist within the geodatabase, right-click on the database connection > Administration > Compress Geodatabase.  After the geodatabase is compressed, you can execute the 'sdelayer -o alter' command and the extent will recalculate.  You can also script the above using the Versioning toolset for the Data Management tools.
0 Kudos
DianaUmpierre
Deactivated User
JSkinn3;271206 wrote:
Hi Ernst,


At 10.1, there is a way to recalculate the extent through the properties of the feature class.  In the Catalog window > right-click on the feature class > Properties > Feature Extent tab. 

[ATTACH=CONFIG]21603[/ATTACH]
QUOTE]

I have 10.1 SP1, but recalculate using the Feature Extent tab did not work for me. It still recalcuated to incorrect extent, covering for areas than what is in my current feature class. In my case, the data resides in ArcSDE, but in a 9.3 SDE on Oracle. Only my client is ArcGIS Desktop 10.1. Is this a bug in 10.1 SP1? Has ESRI created a bug # for this issue?
0 Kudos