13

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...

4

http://support.esri.com/em/knowledgebase/techarticles/detail/41763

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
3

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.

  • 1
    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
2

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.

1

The following script downloads hosted Feature Layer attachments to disk: Downloading Feature Layer Attachments via the ArcGIS API for Python. It uses the latest ArcGIS API for Python which interacts directly with any Web GIS.

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.