The code below works for points however when I switched the feature type to POLYGON it correctly copies the attributes, but does not actually create polygons. For example, the attribute table is populated, but the SHAPE_length and SHAPE_Area fields show as zero. Is there perhaps something in this code that allows it to only be compatible with a point feature class instead of a polygon feature class? The attribute table is shown below as well. The input feature class is a polygon and has a defined shape_area and shape_length which are not being carried over into the output feature class.
Any help is appreciated. Thank you!
def main(): import arcpyimport os fc_in = r"input.gdb\inputfeatureclass" # this one exists fld_count = "PHASE_COUNT" fc_out = r"input.gdb\outputfeatureclass" # this one will be createdarcpy.env.overwriteOutput = Truesr = 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, cnt): curs_out.insertRow(row) if __name__ == '__main__': main()
أكثر...
Any help is appreciated. Thank you!

def main(): import arcpyimport os fc_in = r"input.gdb\inputfeatureclass" # this one exists fld_count = "PHASE_COUNT" fc_out = r"input.gdb\outputfeatureclass" # this one will be createdarcpy.env.overwriteOutput = Truesr = 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, cnt): curs_out.insertRow(row) if __name__ == '__main__': main()
أكثر...