Select to view content in your preferred language

Is it possible to set the extent of a feature class programmatically using ArcPy

751
5
09-26-2024 11:50 AM
Labels (3)
ChenChen4
Regular Contributor

I have 500+ feature classes stored in an Enterprise Geodatabase. The goal is to update extent to each feature class to match the Organization's extent. Does ArcPy have the function to perform this task? 

Tags (2)
0 Kudos
5 Replies
DuncanHornby
MVP Notable Contributor

Yes it would be very easy, you use the Describe object on a dataset.

0 Kudos
ChenChen4
Regular Contributor

Thanks my friend. I know how to GET the extent of a feature class:

desc = arcpy.Describe(fc)
xmin = desc.extent.XMin
xmax = desc.extent.XMax
ymin = desc.extent.YMin
ymax = desc.extent.YMax

But what I need is to RESET the extent. I know I can change the output extent in the environment settings using the Extent class, but this only defines what features will be processed by a tool. It does not alter the actual geometry of the feature class:

arcpy.env.extent = arcpy.Extent(-107.0, 38.0, -104.0, 40.0)

Thanks

 

0 Kudos
MarcoBoeringa
MVP Alum

Well, there is the:

Recalculate Feature Class Extent (Data Management)

geoprocessing tool that you could easily call from ArcPy. Do note though that it requires an exclusive schema lock, which might be problematic in some cases.

It also calculates the extent based on the actual features according to the Help page, while your first post suggests setting a predefined "organization" extent that may not reflect the actual data's true extent.

I am not sure if that is possible with the ESRI tools, or if you would need to hack into the geodatabases system tables to achieve that.

0 Kudos
ChenChen4
Regular Contributor

Thanks.

There is no input parameters to set xmin, ymin, xmax, and ymx in the RecalculateFeatureClassExtent function. It simply updates the x,y,z and m extent properties of a feature class based on that's already set in that feature class. It won't allow me to set the custom xmin, ymin, xmax, and ymax values. 

I'm exploring the update cursor option and trying to figure out if I can do so by altering a feature class @SHAPE attribute.

0 Kudos
BobBooth1
Esri Regular Contributor

You could Clip the feature classes to your organization's preferred area. This would remove data outside that area.

0 Kudos