ArcPy create parameter for coordinates input

317
3
08-09-2021 11:45 AM
MoEbra
by
New Contributor

I wrote a python script that draw polygon feature using coordinates, how could I convert this code to ArcPro tool box.

I used arcpy.getparameters() for input feature

but I don't know how to add coordinates as user input in the tool.

 

 

 

 

import arcpy
import os
#feature_class = arcpy.GetParameterAsText(0)
#coordinates= arcpy.GetParameterAsText(1)
feature_class = r"################"
coordinates = [(3469805.71, 3507667.98), 
               (3469777.30, 3507674.77), 
               (3469778.07, 3507637.08)]
# Write feature to new feature class
with arcpy.da.InsertCursor(feature_class, ['SHAPE@']) as cursor:
    cursor.insertRow([coordinates])

 

 

 

 

0 Kudos
3 Replies
DavidPike
MVP Frequent Contributor

you might find a script tool the easiest to create initially Create a script tool—ArcGIS Pro | Documentation

what is coordinates = [] intended to be doing?

MoEbra
by
New Contributor

I update the script, the coordinates is a list and must take at least 3 points(x,y) to draw a polygon, so I want to know how to convert this to user interface which include:
1 - input polygon FC. (already used GetParameterastext(0) and add it into tool properties parameters.

2- three input required parameters (x,y), also user could add extra points (and it's the problem)

0 Kudos
curtvprice
MVP Esteemed Contributor

Your code won't work right now in any environment. You need to create a shape object using arcpy.Polygon(), you can't just stuff a list of coordinates in a shape field. Good examples in the help:

ArcGIS Pro Help: Writing Geometries

Once you get this working at the Python command line (or a python notebook) then you can go ahead and create a script.