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?
Yes it would be very easy, you use the Describe object on a dataset.
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
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.
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.
You could Clip the feature classes to your organization's preferred area. This would remove data outside that area.
Has anyone identified a solution to the orignial question?
I have a similar issue. I am looking to create an empty point feature class that has a defined extent base on our organizational area defined by a polygon. I'd like to define all extents in the database at that bounding box extent. Not having the ability to define an extent on the point feature class will require continuously updating the extent as the feature class is popluated with data rather than at creation.
A workaround would be add points at the corners of the bounding box, recalculate extent, then delete the points, but seems like there should be a better way.
Understanding the issue
I think there are several solutions buts worth understanding why things are what they are. When you create a Feature Class you typically need to set a coordinate system as that's how the GIS knows where your data is. Don't set a coordinate system then your data could just a easily be on the moon. That's a "sphere" just like Earth...
If you read the help file for the tool I link to above the coordinate system parameter tells you that you can set xy domain via the environment settings of the tool. But all that glitters is not gold... Go to the help page for xy domain environment and it states "...geodatabases automatically calculate a valid x,y domain based on the coordinate system". SO.. tools force a xy domain based upon the coordinate system of the data. That makes sense, as you create your features they need to exist somewhere and that is your coordinate system.
Possible solution #1
But! You can create a Feature Class without a coordinate system (you simply don't provide one for that parameter) and ONLY THEN can you set the xy domain.
So now you have a dataset that has an unknown coordinate system but an xy domain extent you set. But you can't edit into it! Note if you have a dataset with no coordinate system then ArcPro refuses to allow you to edit it. All a bit chicken 'n' egg.
But there is a sort of a legacy tool from the past which is define projection , this allows you to set the coordinate system of a dataset which was unknown.
Finally you have a featureclass that has a coordinate system, a user define xy domain extent and is editable.
But... I can't say with certain, go run one of the many other tools on your data and they simply reset the extent to the domain of the coordinate system. So a complete waste of time...
Possible (untested) solution #2
Modern versions of ArcPro have massively expanded the capability of a geodatabase through attribute rules. Arcade code that gets executed when you insert/edit a feature. It would take very little code to query the geometry and ask does it fall within the extent of a predefined area, if not reject the edit. Rules are associated with layers in your project.
I would suggest solution #2.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.