Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

ArcGIS 10 features the new ability to add attachments to individual features to feature classes stored in a geodatabase. One use of this would be to add multiple pictures to a specific location, fire hydrants seem to be a popular example (important to know if you're a dog on the internet in need of a pit stop I suppose).

In the database the structure of an attachment enabled feature class is trifold:

  • the feature class itself,
  • a table holding the attachments and associated metadata (filename, size, etc), and
  • a relationship class defining the 1-to-many relationship between the two.

the 3 items that comprise an attachment-enabled feature class

My question is: how to export this data -- feature class, attachments, attachment metadata -- for consumption outside of Arcgis?*

Exporting the FC is easy, FeatureClassToFeatureClass works the same as on a non-attachment enabled FC. Exporting the table of attachments? Not so much. TableToTable to output.dbf extracts the attached file metadata only, to output.csv errors out with unsupported field type, and to output info table fails with a general field error.

This isn't all that surprising as those file types don't support a binary blob datatype. I was expecting/hoping to find a tool which would convert the attached binaries into their native format, e.g.

table to file system diagram

So, how about it? What do I need to do to get the data out?

* ironically my project of the moment which spawned this Q is to export for use within Arcgis, just not Arcgis Desktop...

share|improve this question
up vote 4 down vote accepted

For ArcGIS 10.1+

from arcpy import da
import os

inTable = arcpy.GetParameterAsText(0)
fileLocation = arcpy.GetParameterAsText(1)

with da.SearchCursor(inTable,['DATA','ATT_NAME']) as cursor:
   for row in cursor:
      binaryRep = row[0]
      fileName = row[1]
      # save to disk
      open(fileLocation + os.sep + fileName, 'wb').write(binaryRep.tobytes())
      del row
      del binaryRep
      del fileName
share|improve this answer
thank you ian! This works, but is really just a starting point to a real solution. The exported files are just dumped in a common folder, losing the relationship to the source record. In comments there is a method described to use Record_ID as the filename; too circuitous for me, and doesn't accommodated multiple attachments, but it is better than the default. – matt wilkie Jun 17 '14 at 18:31
Some more resources to help with a python approach: *… * * – matt wilkie Jan 19 '15 at 22:55

Exporting GDB to XML (by right clicking on GDB> Export to XML) can perfectly export features+attachments. Moreover, if you are looking for a more automated approach, ArcGIS 10.1 features a new toolbox for XML export. You can import XML into new GDBs or directly access all its data by parsing it for other applications.

share|improve this answer
This approach sounds intriguing, however I don't have any tools (I don't think) which would be able to use the .xml either. So I'd be just trading one opaque format for another. However at least with .xml there is potential for access and re-use. I'll explore this path when we get 10.1 deployed. – matt wilkie Nov 4 '12 at 5:07

I have not tried next methods, so just my thoughts about it:

If you are convenient with ArcGIS .NET API you can use C# to export blobs to files. Take a look at this snippet.

Also may be you can try to export attachment table to Personal GDB and then try to export blobs there. Same way you can export to SDE table and use you DBMS (sql?) to perform it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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