[GIS] Points from python directly to ArcMap

arcgis-10.1arcgis-desktoparcpy

I have a python code that is generating coordinates one by one. Is there a way to display them directly in ArcMap as they are generated? I am aware of the insert cursor but the lock on the table prevents python from writing into it.

Ok, now that I used the Python window in ArcMap new error has occured. Could it be because the "czk" is a list?

Here is the code:

czk=[413960.0, 47130.0]
cursor = arcpy.da.InsertCursor("C:/GIS/AlJeba/Tocke/Tocke.shp", ("SHAPE@XY"))
for row in czk:
    cursor.insertRow(row)
del cursor

And here is the error:

Runtime error
Traceback (most recent call last):
File "", line 333, in
TypeError: argument must be sequence of values

Best Answer

The problem is that you are passing in Shape@XY as the argument for the field names. This expects a tuple of the feature's centroid x,y coordinates to be passed in when you use the insert cursor ( see http://resources.arcgis.com/en/help/main/10.1/index.html#//018w0000000t000000)

However, czk=[413960.0, 47130.0] is a list containing two floating point numbers. When you say:

    for row in czk:
        cursor.insertRow(row)

You are only passing a single floating point number in when it expects a tuple with two items in it (one x and one y coordinate).

If 413960.0, 47130.0 is your x,y pair then you need to change your code to something like this:

    czk=(413960.0, 47130.0)
    cursor = arcpy.da.InsertCursor("C:/GIS/AlJeba/Tocke/Tocke.shp", ("SHAPE@XY"))
    cursor.insertRow(czk)
    del cursor