arcpy script tool: creating a point feature from user input XY coordinate

المشرف العام

Administrator
طاقم الإدارة
This part of my tool is giving me issues.I want to create a new feature class based on the user's input workspace, then generate a new point feature within that feature class based on the user's input XY coordinates.

So far this is what I have.My script tool calls for the input DEM (Parameter 0) (this is needed for a later process).an XY coordinate (Parameter 1)and an output workspace (Parameter2)

The input XY coordinates are split, space delimited.From here the Xcoord and Ycoord can be read in as type floating point and used to generate the point feature.

Problem is: Everytime, no matter what coordinate inputs used, the point is placed at

-81.511127 37.576795 Decimal Degrees

Even if I enter 0,0 for coordinates...

Is there something I am missing?How can I create a new point feature using the Xcoord and Ycoord input from the tool?

Here is my code:

import arcpyfrom arcpy import envfrom arcpy.sa import *from arcpy.da import *env.overwriteOutput = Truearcpy.CheckOutExtension("3D")arcpy.CheckOutExtension("Spatial")DEM = arcpy.GetParameterAsText(0)CoordsIn = arcpy.GetParameterAsText(1)Workspace = arcpy.GetParameterAsText(2)CoordSplit = CoordsIn.split(" ");Xcoord = (CoordSplit[0])Ycoord = (CoordSplit[1])arcpy.AddMessage(Xcoord)arcpy.AddMessage(Ycoord)PointName = "pourpoint.shp"GeomType = "POINT"Template = ""Has_m = "DISABLED"Has_z = "DISABLED"SpRef = arcpy.Describe(DEM).spatialReferencearcpy.CreateFeatureclass_management(Workspace, PointName, GeomType, Template, Has_m, Has_z, SpRef)fc = Workspace + "/" + PointNamecursor = arcpy.da.InsertCursor(fc, ["SHAPE@XY"])xy = (float(Xcoord), float(Ycoord))cursor.insertRow([xy])del cursorarcpy.AddMessage(xy)

أكثر...
 
أعلى