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="")
1

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

  • 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 – Sebastian Salazar May 16 '18 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? – Hornbydd May 16 '18 at 17:22
  • Hornbydd. Yes I was wrong. n my first test I exported the shp file to a .dbf table. – Sebastian Salazar May 16 '18 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. – Sebastian Salazar May 16 '18 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.