I am writing a script that populates a field full of Lat/Long coordinates and most likely should be a tuple. Originally I just created a Lat/Long tuple pair nested within a list and set equal to a variable. Ex: coords =[(34.456548, -119.710025)].
Now I am trying to create a for loop that will be able to take a users Lat,Long input as an argument and then populate a field named Lat_Long with that user input.
Here is the code so far Code:
import os, arcpy
coords = input([(),()])
new_shp = arcpy.CreateFeatureclass_management(r"C:/geodata","test_4.shp", "POINT", spatial_reference=4326)
arcpy.AddField_management(new_shp,'Lat_long', 'LONG')
with arcpy.da.InsertCursor(new_shp,['SHAPE@XY']) as icur:
for coord in coords:
print("Inserted {} into {}\n".format(coords,new_shp))
icur.insertRow([coord]
print(new_shp)
print("Script_Complete!)
This code creates an empty shapefile along with the other files eg. shx. and are put into a the specified directory. Would there need to be another for loop to iterate over the shapefile and produce new rows of Lat/Long user input?