Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Has anyone succeeded in programmatically updating metadata in ArcGIS 10? Considering using Python/arcpy but ArcObjects (C# or Python/comtypes) is also a possibility.

I need to update both the FGDC and the ArcGIS-ISO format metadata, and whatever solution is used needs to be able to retain the existing (non-blank) elements along with the added elements, except where they are in conflict in which case the added elements overwrite the existing elements.

share|improve this question
add comment

4 Answers

up vote 6 down vote accepted

The easiest way to do this from arcpy is to create an xml file using python and then invoking Import Metadata (Conversion). However, this will overwrite everything.

An alternative is to use ArcObjects to obtain an IName to the dataset, cast to IMetadata, and edit the IPropertyset.

share|improve this answer
add comment

We have been struggling with this and solved it by having a simple python library built around the arcobjects metadata functions. It's based on a xml-file where the metadata values have been replaced with keywords. You can use these keywords in your python code to get or set the value of a metadata field. Code woud look something like this:

import dataprocessing
DP = dataprocessing.create()

md = DP.OpenMetadata("C:/MyShapefile.shp") # Works also on geodatabases
myKeyword = "%FGDC.abstract" # Keywords have to start with '%' but the rest is up to you

if md.GetValue(myKeyword) == "Not what I want":
    md.SetValue(myKeyword, "New value that suits me better")

The tool can be found here: http://www.aris.nl/dataprocessing_arcgis and is freely available. The version on the website is for arcgis 9.3. An arcgis 10 version will be available but it will no longer be free.

(Full disclosure: I work for a dutch government agency where we had the current version of this tool built partly from taxpayers money and partly from time donated by the programmer. That's why it's available for free but not open source. As of 2013 we will not be funding any new versions. I'm not making any money out of it in any way. I just hope it gets put to more use.)

share|improve this answer
add comment

A third option I'm looking into now is to use an XSLT file along with the XSLT Transformation (Conversion) tool. I'm pretty much having to learn the language as I go though, and they don't make it easy on you by using the .NET implementation which uses the older XSLT/XPath 1.0 standards.

share|improve this answer
    
And Python doesn't even include an XSL Transformer for some crazy reason! –  James Schek Mar 23 '11 at 15:54
1  
There aren't pure python implementations of many libraries, its fairly common to have something which is just a wrapper to a much faster C/C++ library, which I think is the case here: stackoverflow.com/questions/138502/pure-python-xslt-library –  scw May 15 '11 at 6:38
add comment

I have some code that uses ArcPy and DOM for conversion of existing MD, creation from scratch (if none exists) and update of certain elements using DOM. It's a bit clunky, with quite a lot of hardcoded pathnames and so on.

share|improve this answer
1  
It's a kind offer, Steve, and much appreciated, but it's not consistent with this site's aims or structure. Please read our FAQ for more information. Unless the code is really long, you should be able to post it in a reply. –  whuber Feb 15 '12 at 16:30
add comment

Your Answer

 
discard

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.