I use ArcGIS 10.1 without Data Interoperability extension and I want to convert some feature classes (point, lines and polygons) contained in an .mdb. I read some posts but can't convert my file.

This is the code I have (that does not work):

import arcpy
for row in cur:
    x,y = row[0]
    print ("{0},{1}".format(x,y))

Some one can help me?

I saw this link:

Converting geometry to WKT using ArcPy?


I try with this but the result is:

import arcpy
infc = arcpy.GetParameterAsText(0)
for row in arcpy.da.SearchCursor(infc, ["OID@", "SHAPE@WKT"]):
    print("feature {0}:".format(row[0]))
    partnum = 0
    for part in row[1]:
        print("Part {0}:".format(partnum))
        for pnt in part:
            if pnt:
                print("{0}, {1}".format(pnt.x, pnt.y))
                print("Interior Ring:")

Parsing error SyntaxError: invalid syntax (line 9)

I tried with what you suggested but the result is:

import arcpy

shp = r"C:\Lavoro\prova_arcpy\punt.shp" with arcpy.da.SearchCursor(shp,['SHAPE@WKT']) as cur: for row in cur: print row[0]

Runtime error Traceback (most recent call last): File "", line 2, in RuntimeError: unknown geometry token 'SHAPE@WKT' What do you recommend?

Someone can explain me the real difference between JSON and GeoJSON?

I was able to use this script to save in a .txt geometry but my problem is that I save only the geometry in 2D and I do not export attributes related to geometry.

import arcpy

shp = r"C:\Lavoro\prova_arcpy\lin.shp"
f= open ("C:/Lavoro/prova_arcpy/conv.wkt","w")
with arcpy.da.SearchCursor(shp,['SHAPE@WKT']) as cur:
for row in cur:
        f.write("wkt_geom "+row[0])


How can I do?

  • 1
    Please review this webpage for instructions on how to format the code and other styling in your questions/answers.
    – GeoSharp
    Oct 28, 2015 at 8:12
  • I converted your "answer" into an edit to your question because the area reserved for answers should only be used for that purpose. There is an edit button beneath your question to use for revising it with new details.
    – PolyGeo
    Oct 28, 2015 at 8:38

1 Answer 1


You are defining your cursor incorrectly. You need to use the keyword with in order to work with arcpy.da (data access module) cursors. (Note that there is an old cursor , which you should not use, and a new cursor, which you should use)

Here is how to set up a da cursor and print out the WKT of each feature:

import arcpy

shp = r"D:\Python\ArcPy\Testing\airports_eur.shp"

with arcpy.da.SearchCursor(shp,['SHAPE@WKT']) as cur:
    for row in cur:
        print row[0]

I am using a point shapefile, so the output looks like this:

POINT (4.4338443496287647 51.949130189938153)
POINT (8.7858617703132005 53.052287104156015)
POINT (15.067460500705343 37.470072800341015)
POINT (8.7129595350243676 45.627440514038092)
POINT (11.077417973909556 49.494505217034451)
  • SHAPE@JSON, SHAPE@WKB, and SHAPE@WKT tokens were made available at ArcGIS 10.1 Service Pack 1. resources.arcgis.com/de/help/main/10.1/index.html#//…
    – nickves
    Oct 28, 2015 at 12:17
  • 2
    You dont need to use 'with' with the da.Cursors.... but it is good form. This returns the exact same results as your code: for row in arcpy.da.SearchCursor("point", ["SHAPE@WKT"]): print row[0]
    – KHibma
    Oct 28, 2015 at 13:29
  • I actually was not aware of that; good to know! But since the problem with the old cursors (despite being slower) was that one often forgot to delete them after using, it makes sense to always go with the with, as it takes care of that. One would not want to create even more schema locks and such ;-) Oct 29, 2015 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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