Generate dynamic input with python script

4413
1
11-11-2014 11:39 AM
GustavoCordero
New Contributor III

I'm new to this topic as I can use sys.argv [] or GetParameterAsText?

for can I make dynamic input coordinates and the name of the output shapefile

I'm using 10.2.2 ArcGIS, I want to create a python script and have the following script:

 

arcpy.env.workspace = 'C:\Users\Modelo\Puntos.gdb'
arcpy
.env.overwriteOutput = True
sr
= arcpy.SpatialReference('WGS 1984')
arcpy
.env.outputCoordinateSystem = sr
latitude
= 14.024982
longitude
= -89.962368
p
= arcpy.Point(longitude, latitude)
pg
= arcpy.PointGeometry(p)
arcpy
.CopyFeatures_management(pg, 'salida.shp')

 

0 Kudos
1 Reply
NeilAyres
MVP Alum

A few thing here...

When making geometries, supply the spatial reference :

pg = arcpy.PointGeometry(p, sr)

Your output shouldn't be a shapefile (*.shp) if its going into a gdb.

You have to make your python code into a script tool.

You use the GetParameterAsText(#) for each of your inputs.

Then the script can be added to a toolbox as a script tool.

Each input needs to have its properties set, so the tools knows what sort of input is expected (workspace, feature class etc)

See here:

http://resources.arcgis.com/en/help/main/10.2/index.html#//001500000006000000

http://resources.arcgis.com/en/help/main/10.2/index.html#//00150000000n000000

0 Kudos