I have to Clip the data in a file Geodatabase in which there are about 80 Feature Datasets which includes about 20 feature classes in each one of the Feature Datasets.
I have created the model once which iteration of "Feature Classes", once with "Datasets" and once with " Workspace".
I was able to do some clipping but None of them do it through the whole GDB and just get the first Feature dataset. How can I make it automatically for the whole FGDB?
-
Should all feature classes be clipped with the same clip features? Where do you want to store all outputs?Bera– Bera2018年11月09日 14:18:48 +00:00Commented Nov 9, 2018 at 14:18
-
That is true. All the Features are supposed to Clip . It is possible to save them even in a new FGDB.Chiki2025– Chiki20252018年11月12日 09:11:58 +00:00Commented Nov 12, 2018 at 9:11
1 Answer 1
This is easier with arcpy. If you dont want an arcpy solution I can delete my answer.
Script will list all feature datasets in database, and for each list all feature classes and then clip with specified clip feature. Outputs will be placed in the same feature dataset and with '_clipped' appended to name.
Make sure you have no feature datasets or feature classes in the database but the ones you want clipped.
import arcpy, os
arcpy.env.addOutputsToMap = False #Remove this line if you want all outputs to be added to the map
database = r'C:\Somedatabase.gdb' #Change
clip_feature = r'C:\Somedatabase.gdb\eraser' #Change
arcpy.env.workspace = database
datasets = arcpy.ListDatasets(feature_type='Feature')
for dataset in datasets:
arcpy.env.workspace = os.path.join(database,dataset)
features = arcpy.ListFeatureClasses()
for feature in features:
arcpy.Clip_analysis(in_features=feature, clip_features=clip_feature,
out_feature_class=feature+'_clipped')
-
1Thank you very much for your Feedback. I am not really pro in ArcPy but I am going to try it.Chiki2025– Chiki20252018年11月12日 09:10:45 +00:00Commented Nov 12, 2018 at 9:10
-
I tried the Code but I receive errorChiki2025– Chiki20252018年11月12日 09:33:33 +00:00Commented Nov 12, 2018 at 9:33
-
@Chiki2025 what is the error message?Bera– Bera2018年11月12日 09:46:43 +00:00Commented Nov 12, 2018 at 9:46
-
this is the error: Runtime error Traceback (most recent call last): File "<string>", line 4, in <module> TypeError: 'NoneType' object is not iterableChiki2025– Chiki20252018年11月12日 10:02:30 +00:00Commented Nov 12, 2018 at 10:02
-
It works strange. I have limited the featuredatasets to just two and it works. However, when I increase the number of the featuredatasets, it stocks and I get Errors.Chiki2025– Chiki20252018年11月12日 10:40:22 +00:00Commented Nov 12, 2018 at 10:40
Explore related questions
See similar questions with these tags.