Using the command line to convert between metadata formats

Problem: You have a lengthy metadata record that you want to preserve, but it has been created using a different stylesheet than your standard.

Just a few days before I was going to take a course in python scripting, I noticed the command line button on the ESRI toolbars.

It is there in ArcMap and ArcCatalog. I wonder why I’d never noticed it before. Turns out you can do a lot of cool things with it. The portion of every Help document labeled “Command line syntax” is talking about things you can type into the command window. Plus, I learned in my class later that with ArcGIS 10, it will be renamed to the Python Window because we will be able to run python scripts directly from it! But I am getting ahead of myself.

There are certain things you can only do from the command window, and today I will talk about one of them: converting metadata from one format to another. The two prominent metadata standards are FGDC: Federal Geographic Data Committee and ISO: International Organization for Standardization 19115.

If you want to use data from an organization that follows a different standard than you do, you might need to do a conversion. For example, the metadata for World Wildlife Fund’s Global Lakes and Wetlands Database is in FGDC format. In order to view it in ArcCatalog, I need to have an FGDC stylesheet selected.

With the right stylesheet, all of the pertinent information is displayed in the metadata window.

If I switch to an ISO stylesheet, what I see is not nearly as helpful.

You could consign yourself to switching between stylesheets, but I suspect many people work in places that insist all of the metadata for their collection of geospatial records be in the same format. If you need to do a conversion, there is a faster way than typing all of the information back into the metadata creation wizard.

ESRI has provided a set of four metadata translators with the ArcGIS desktop install. They should be located in the \Program Files\ArcGIS\Metadata\Translator folder. You can run these translators from the command line window. First, pick the one you need.

  • FGDC to ISO 19139 (FGDC2ISO19139.xml)
  • ESRI-ISO to ISO 19139 (ESRI_ISO2ISO19139.xml)
  • FGDC to ESRI-ISO (FGDC2ESRI_ISO.xml)
  • ISO 19139 to ESRI-ISO (ISO19139_2ESRI_ISO.xml)

Then press the command line button, and type ESRITranslator into the window. If you press the spacebar, a tool tip will pop up that tells you the arguments you need to enter next. In this case it will say

ESRITranslator <source> <translator> {output} {logfile}

Input within carrots <> is required; input within brackets {} is optional. For me, <source> is the path to the Global Lakes and Wetlands metadata .xml file. <translator> is the path to the ESRI Translator I want to use ( FGDC to ESRI-ISO ). And {output} is the path to where I want to store the new converted .xml file. I’m not going to specify a logfile.

My code looks like this:

(click on image to see full size)

Notice a couple things here. My cursor is in the path to the translator file, and <translator> is bolded in the tool tip. This is intentional. If I move the cursor to other arguments, the bolding will change accordingly. Use this to make sure your syntax is correct.

Also notice that I have surrounded the path to the translator file in quotes. Quotes are optional, but you must use them if you have spaces in your path name. Otherwise the space will be misinterpreted as the beginning of the next argument. Going through and checking what is bolded where will help to catch this sort of thing.

Press enter to run the code. Then, press the Import Metadata button and browse to your new .xml file.

Now it looks how ISO should!

Tags: , , , ,

Leave a Reply

Bad Behavior has blocked 62 access attempts in the last 7 days.