How to convert a tuple into records in a blank feature class, ArcMap Advanced 10.2 &

المشرف العام

Administrator
طاقم الإدارة
How to convert a tuple into records in a blank feature class, ArcMap Advanced 10.2 &

Here is the code block that I am using, it all works great except for the bottom part. I am not sure how to turn the tuple into records on a blank feature class. The tuple looks like this: ('BRONTE DR', 'BRONTE DR', 'RICHARDSON DR', 'RICHARDSON DR'). I want each part of the tuple to be a new record in the blank feature class.

import reimport arcpyfrom arcpy import envarcpy.env.overwriteOutput = Trueif arcpy.Exists(r"J:\STW\Divisions_&_Branches\MSMD\Branches_&_Sections\GIS\users\Anault\intersections_software_development\OUTPUT.gdb\street_assets2"): arcpy.Delete_management(r"J:\STW\Divisions_&_Branches\MSMD\Branches_&_Sections\GIS\users\Anault\intersections_software_development\OUTPUT.gdb\street_assets2")arcpy.env.workspace = r'J:\STW\Divisions_&_Branches\MSMD\Branches_&_Sections\GIS\users\Anault\intersections_software_development\OUTPUT.gdb'table1 = r"street_assets"field1 = r"STREET_OR_INTERSECTION"def unique_values(table, field): with arcpy.da.SearchCursor(table, [field]) as cursor: return sorted({row[0] for row in cursor})newtuple = unique_values(table1,field1)newtuple = str(newtuple)newtuple = newtuple.split("}{")newtuple = ([s.replace('\'', '') for s in newtuple])newtuple = ([s.replace('"', '') for s in newtuple])newtuple = ([s.replace('u', '') for s in newtuple])newtuple = ([s.replace('[', '') for s in newtuple])newtuple = ([s.replace(']', '') for s in newtuple])newtuple = ([s.replace('{', '') for s in newtuple])newtuple = ([s.replace('}', '') for s in newtuple])out_path = r"J:\STW\Divisions_&_Branches\MSMD\Branches_&_Sections\GIS\users\Anault\intersections_software_development\OUTPUT.gdb"out_name = "street_assets2"geometry_type = "POINT"template = r"J:\STW\Divisions_&_Branches\MSMD\Branches_&_Sections\GIS\users\Anault\intersections_software_development\OUTPUT.gdb\street_assets"has_m = "DISABLED"has_z = "DISABLED"spatial_reference = arcpy.Describe(r"J:\STW\Divisions_&_Branches\MSMD\Branches_&_Sections\GIS\users\Anault\intersections_software_development\OUTPUT.gdb\street_assets").spatialReferencearcpy.CreateFeatureclass_management(out_path, out_name, geometry_type, template, has_m, has_z, spatial_reference)newtuple = tuple(newtuple)print newtuple## Problem Herecursor = arcpy.da.InsertCursor(r"J:\STW\Divisions_&_Branches\MSMD\Branches_&_Sections\GIS\users\Anault\intersections_software_development\OUTPUT.gdb\street_assets2", ['STREET_OR_INTERSECTION'])i = 0for i in newtuple: cursor.insertRow() i = i + 1

أكثر...
 
أعلى