ArcMap version 10.3.1 Python version 2.7.12

I'm trying to produce a points table with one row. The row should include x,y coordinates for the point and optionally a name.

I have tried this two different ways and failed, each yielding separate results.

Attempt 1:

(Creates a shapefile, but it is empty and unprojected)

temp is a variable holding '[37.00, -79.00]'

pointslist = []

pt = arcpy.Point()
ptGeoms = []
for p in pointslist:
    pt.X = p[0]
    pt.Y = p[1]

arcpy.CopyFeatures_management(ptGeoms, r"C:\Temp\test.shp")

Attempt 2:

(Always results in the name field being populated, but the x,y remaining null)

fc = "p:/435final/standin.gdb/userx"
cursor = arcpy.da.InsertCursor(fc, ["SHAPE@XY"])
xy = (39.55, -79.00)
cursor.insertRow(["USER", xy])
del cursor 
  • Yes. I have tried addressing the fields as "SHAPE@XY" as well as individually. – rsturtle Nov 21 '16 at 2:24
  • 1
    i copied your attempt one and ran t - it worked for me – ziggy Nov 21 '16 at 2:29
  • also if its just one coordinate you dont need to loop through it – ziggy Nov 21 '16 at 2:29
  • Thank you for letting me know it worked for you. I'll talk to my professor in the morning! – rsturtle Nov 21 '16 at 2:35
  • 1
    it showed up in Antarctica for me though, you have define the spatial reference. where is this supposed to be? – ziggy Nov 21 '16 at 2:38

A few things:

  1. In your first attempt you have a for loop. You do not need to loop through the points list because you only have one coordinate. You can just pass your coordinate values through the arcpy geometries
  2. I ran your code and my point showed up somewhere in Antarctica. So I ran it again and switched your x,y positions and the point showed up in Virginia
  3. Your point needs to be in a coordinate system when creating it because arcmap will tell you that it cannot be drawn without a coordinate system.

Here is what I have assuming you want your point in Virginia and not somewhere on a Antarctic iceberg

point  = arcpy.PointGeometry(arcpy.Point(-79.00,37.00),arcpy.SpatialReference(4326))
arcpy.CopyFeatures_management(point, r"path\noury.shp")
  • Thank you for an informative and well formatted answer. I ended up solving this problem by exporting the coordinates into a text file. I then imported them into ArcMap, using the "MakeXYEventLayer_management" feature. Not ideal, but it got me though. – rsturtle Nov 27 '16 at 23:59

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.