insert DMS coordinates in python tool

Discussion created by bogdanpalade on Aug 22, 2013
Latest reply on Aug 23, 2013 by marcuscole
Dear friends,

I want to make a simple tool where one could insert DMS coordinates and the tool would generate a point shapefile containing one point at the specified coordinates.

For the tool I have three parameters:

1. Output folder (type folder)
2. X coordinates (type string)
3. Y Coordinates (Type string)

If I run it inserting Decimal degrees coordinates, it works fine. If I am inserting DMS coordinates (for example 44°27'2.714"W  39°16'38.993"N) I get an error where it says that "input value is not numeric"). What should I do to make it work with DMS? Should I write the DMS in another way?

Here is the code:

outFolder = arcpy.GetParameterAsText(0)
arcpy.env.workspace = outFolder
outSHP = "MyShape.shp"
sr = arcpy.CreateSpatialReference_management("path to the WGS 1984.proj")
arcpy.CreateFeatureclass_management(outFolder, outSHP, "POINT", "#", "#", "#", sr)
Xcoord = arcpy.GetParameterAsText(1)
Ycoord = arcpy.GetParameterAsText(2)
cur = arcpy.InsertCursor(outSHP)
bgd = cur.newRow()
pnt = arcpy.CreateObject("Point")
pnt.X = Xcoord
pnt.Y = Ycoord
bgd.shape = pnt
del cur, bgd

Thank you very much!