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
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
-
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. ThanksSebastian Salazar– Sebastian Salazar2018年05月16日 16:56:02 +00:00Commented 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?Hornbydd– Hornbydd2018年05月16日 17:22:52 +00:00Commented May 16, 2018 at 17:22
-
Hornbydd. Yes I was wrong. n my first test I exported the shp file to a .dbf table.Sebastian Salazar– Sebastian Salazar2018年05月16日 17:55:59 +00:00Commented 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.Sebastian Salazar– Sebastian Salazar2018年05月16日 18:02:17 +00:00Commented May 16, 2018 at 18:02
lang-py