0

I need to export 150 polygons from a feature Class. I have a python snippet code to export the polygons one by one. I think a for loop code can do it fast, but I don't know how to write the code into the loop. Can anyone tell me how to do it?

arcpy.FeatureClassToFeatureClass_conversion(in_features="D:/ASSUKKARGIS3/ty_plg_gglimgs_georef/plg_clip_imgs.shp", out_path="D:/ASSUKKARGIS3/plg_clips", out_name="001_clip_plg.shp", where_clause='"plg" = 1', field_mapping='plg "plg" true true false 19 Double 0 0 ,First,#,D:\ASSUKKARGIS3\ty_plg_gglimgs_georef\plg_clip_imgs.shp,plg,-1,-1', config_keyword="")
Bera
81.7k14 gold badges85 silver badges199 bronze badges
asked May 16, 2018 at 13:13

1 Answer 1

1

Why bother writing any code? Simply use the Split By Attributes tool. This came in as of version 10.5

answered May 16, 2018 at 13:42
4
  • Hornbydd. I tested Split By Attributes and the final product is another table. Meanwhile, I wrote the snippet code 150 times changing the field value and the name of the output feature class. This long code was time-consuming but, I have all polygons shps that I need. Thanks Commented May 16, 2018 at 16:56
  • You must have done something wrong, you need only supply the input dataset, the field to split on (e.g. FID) and an output workspace; to only get one table would suggest you may have had a selection on your dataset or you selected a field with no variation in value? Commented May 16, 2018 at 17:22
  • Hornbydd. Yes I was wrong. n my first test I exported the shp file to a .dbf table. Commented May 16, 2018 at 17:55
  • Hornbydd. Yes, I was wrong. In my first test, I exported the shp file to a .dbf table and then use the Split By Attributes tool. The second test I use the shp file and the result is what you say. Thank you very much indeed. Commented May 16, 2018 at 18:02

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.