0

I am performing zonal statistics as table on many rasters (different years of data). I would like to write the result to a table that I can edit, so that I can rename the "SUM" column and left join the results to the previous table iteratively. This way, after my loop is done, I have columns: OBJECTID, SUM_2001, SUM_2002, SUM_2003, SUM_2004... as my resulting table.

How do I write my results to a table that lives in memory and is editable, as opposed to a file?

1

I'd make use of the in_memory workspace to store your table.

ArcGIS provides an in-memory workspace where output feature classes and tables can be written. Writing geoprocessing output to the in-memory workspace is an alternative to writing output to a location on disk or a network location. Writing data to the in-memory workspace is often significantly faster than writing to other formats such as a shapefile or geodatabase feature class. However, data written to the in-memory workspace is temporary and will be deleted when the application is closed.

esri's example:

import arcpy

table = arcpy.CreateTable_management("in_memory", "table1")
arcpy.AddField_management(table, "Field1", "TEXT", field_length=20)

cursor = arcpy.da.InsertCursor(table, ["Field1"])
cursor.insertRow(["Hello World"])

Use Alter Field for changing field names.

Rename fields and field aliases, or alter field properties.

| improve this answer | |

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.