Trying to print out a polygon shapefile in WKT format in a standalone script. I am using ArcGIS 10.1 and use the da modules all the time. I have seen this post Converting geometry to WKT using ArcPy? and have copied and pasted that code to use on my polygon shapefile and it does not work. The error I get is

RuntimeError: unknown geometry token 'SHAPE@WKT'

import arcpy
arcpy.env.workspace = "C:\\Users\\Ralph\\Desktop\\sql"
shp = "C:\\Users\\Ralph\\Desktop\\sql\\states2.shp"
for row in arcpy.da.SearchCursor(shp, ["SHAPE@WKT"]):
    print row[0]

I know it is mentioned in the above post that this token was made available for service pack 1. I am starting to think I do not have service pack 1 nor do I know how to check if I have it. I plan on reading this polygon in a easy format so I can import it using psycopg2 to postgreSQL. Is there another way to read polygon geometries for this task only by using Arcpy?


2 Answers 2


I have had more success when I specify just SHAPE@ as my cursor field and then request the WKT (or other formats) when querying each row. Try changing where you request the WKT:

for row in arcpy.da.SearchCursor(shp, ["SHAPE@"]):
    print row[0].WKT

I suspect that the reason you get that error message is that your version of ArcGIS may be too early.

The ArcGIS 10.4 for Desktop Help on arcpy.da.UpdateCursor() says that it is a valid syntax:

SHAPE@WKT —The well-known text (WKT) representation for OGC geometry. It provides a portable representation of a geometry value as a text string.

My recollection was that this particular token was added a version or two after ArcPy Data Access and the SHAPE@ token first became available at 10.1 and https://gis.stackexchange.com/a/58362 from @KHibma says:

Note: SHAPE@JSON, SHAPE@WKB, and SHAPE@WKT tokens were made available at ArcGIS 10.1 Service Pack 1.

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.