0

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 arcpy
from arcpy import env
from arcpy.sa import *
from arcpy.da import *

env.overwriteOutput = True

arcpy.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).spatialReference

arcpy.CreateFeatureclass_management(Workspace, PointName, GeomType, Template, Has_m, Has_z, SpRef)

fc = Workspace + "/" + PointName

cursor = arcpy.da.InsertCursor(fc, ["SHAPE@XY"])
xy = (float(Xcoord), float(Ycoord))
cursor.insertRow([xy])
del cursor

arcpy.AddMessage(xy)
  • What's the result if you create a point object like xy = arcpy.Point(float(Xcoord), float(Ycoord))? – Paul Nov 25 '15 at 2:27
1

Your code worked for me! Maybe your in DEM is using a different coordinate system that the input coordinates? What happens if you point to a DEM that uses something like WGS84 (and so your out file gets WGS84, and the input coordinates are referencing WGS84. Oh, and use error handlers to make your life easier! http://resources.arcgis.com/en/help/main/10.1%20/index.html#//002z0000000q000000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.