Hello. I posted this question yesterday(<https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end-arg...>) and thought it was solved, but there's another problem found...
I've run the module below. The empty feature class was created but there's no geometrical shapes created.
def main(): import arcpy import os fc_in = r"D:\forest\CHISAN\shp\test.gdb\PT_merge" # this one exists fld_count = "Count" fc_out = r"D:\forest\CHISAN\shp\test.gdb\PT_merge_duplicate" # this one will be created sr = arcpy.Describe(fc_in).spatialReference # create the empty output featureclass path, name = os.path.split(fc_out) arcpy.CreateFeatureclass_management(path, name, "POLYGON", fc_in, "SAME_AS_TEMPLATE", "SAME_AS_TEMPLATE", sr) # insert the features into the output fc with arcpy.da.SearchCursor(fc_in, '*') as curs_in: flds_in = curs_in.fields idx_cnt = flds_in.index(fld_count) with arcpy.da.InsertCursor(fc_out, '*') as curs_out: for row in curs_in: cnt = row[idx_cnt] for i in range(0,int(cnt)): curs_out.insertRow(row) if __name__ == '__main__': main()
I think something is wrong with "# insert the features into the output fc" part.
Would be very appreciated if someone could lectuer me how to solve this problem.
Thanks for the reply. The module run with no error code, but just the empty feature class was output, which have the database multiplied a number of times based on the numeric field "Count". The database file has been created collectly without the geometrical shape feature 😞
The original question in your previous post indicates the purpose of the script.
I have a point feature class with a Count field. I want to copy each feature in the feature class a number of times based on the number in the Count field. For example, if a feature has a Count value of 6, I want six new features created with all the same attributes as the original feature.
So... to confirm you have a point featureclass and you want to replicate each feature a certain number of times based on a Count field?
@XanderBakker produced a toolbox as well, perhaps you should look at that as well
Thanks for your reply. I have a polygon feature instead of point feature, so I changed the line below from "POINT" to "POLYGON".
arcpy.CreateFeatureclass_management(path, name, "POLYGON", fc_in, "SAME_AS_TEMPLATE", "SAME_AS_TEMPLATE", sr)
Probably that's why the shape feature was not made..?