import arcpy
# Retrieve input parameters
inX = arcpy.GetParameterAsText(0)
inY = arcpy.GetParameterAsText(1)
inDescription = arcpy.GetParameterAsText(2)
incidentsFC = "C:/Data/Yakima/Incidents.shp"
descriptionField = "DESCR"
# Make a tuple of fields to update
fieldsToUpdate = ("SHAPE@XY", descriptionField)
# Create the insert cursor
with arcpy.da.InsertCursor(incidentsFC, fieldsToUpdate) as cursor:
# Insert the row providing a tuple of affected attributes
cursor.insertRow(((float(inX),float(inY)), inDescription))
I came across this script tool in an online course which shows an example for using the Insert Cursor where we insert a row in a point shape file. I couldn't understand something here. Do we somehow specify what 'type' of input we will provide when we use GetParameterAsText()
? If yes, then why do we need to specify again in the last line that the coordinates given earlier are float type? Can't we just write cursor.insertRow((inX, inY), inDescription)
And if No, then how does python understand the input in the variable inDescription
is a string/text without using the double quotes anywhere?
Aucun commentaire:
Enregistrer un commentaire