Importing metadata with different geoprocessing tools

You can import metadata from an ArcGIS item or a stand-alone metadata XML file with different geoprocessing tools, each of which is appropriate in different situations.

Metadata stored in text or HTML format or in a Microsoft Word document or a database can't be imported. The information must be converted to XML format before it can be handled by any of the ArcGIS metadata geoprocessing tools.

Import Metadata

Import Metadata can be used to

If the metadata you want to import isn't ArcGIS metadata, this tool supports converting some metadata formats to ArcGIS metadata before importing the resulting information. The source metadata is processed to remove information that is not appropriate to import before the information is converted.

When this tool imports metadata, it leaves the existing thumbnail, geoprocessing history, unique identifiers, and other important information intact for the target ArcGIS item. The rest of the target item's metadata is replaced with the imported information.

After being imported, the target item's metadata will be updated to contain its current properties.

Metadata Importer

Metadata Importer should only be used to import ArcGIS metadata. The source metadata is copied to the target ArcGIS item without changing it in any way.

Always use the Import Metadata tool to copy information from one ArcGIS item to another or to bring external metadata into ArcGIS.

Use the Metadata Importer tool to update existing metadata.

For example, if you need to update an address and phone number in existing metadata for many ArcGIS items, you can best handle this with a model or Python script that uses the XSLT Transformation tool. The XSLT stylesheet performing the update must copy all existing metadata except for the targeted change it is designed to make—when the stylesheet finds the address and phone number to be updated, they are replaced with the new information. The XSLT Transformation tool exports the updated metadata to an XML file, which must then be copied and sent back to the ArcGIS item using the Metadata Importer tool as illustrated below.

A geoprocessing model for updating metadata with an XSLT stylesheet.

Learn more about creating an XSLT stylesheet to update contact information

When you are updating existing metadata for an ArcGIS item, you want to keep the geoprocessing history, unique identifiers, thumbnail, and all other information in the source item intact; therefore, the Metadata Importer tool is the correct one to use.

Importing FGDC metadata not in XML format

If you have metadata describing a GIS resource stored in text or HTML format or in a Microsoft Word document, additional work is required to get the information into the correct format before you can use it in ArcGIS.

FGDC metadata is commonly available in XML, text, SGML, or HTML formats. The Import Metadata and Metadata Importer tools only handle metadata in XML format. If you received an item from somewhere else that you have started using in ArcGIS and the item came with FGDC metadata, that metadata may not be in XML format. How you can import the information to ArcGIS depends on its format.

FGDC metadata in text or SGML format can be converted to XML format using the metadata parser utility, mp. The mp utility is created and maintained by the USGS—it is not an ESRI utility; a version of this utility is provided with ArcGIS for Desktop. To use mp directly, run it from the operating system's command line. Detailed information about this tool is available from the USGS metadata tools Web site.

You can perform this conversion in Python using the os.system() command. The current directory must be set to the directory where mp.exe is located for the tool to run successfully; the version of this utility provided with ArcGIS is located in the <ArcGIS Install Location>\bin directory.

Convert FGDC text file to XML using mp

Converts a structured text file formatted following mp's requirements to the FGDC CSDGM XML format. The resulting XML file can be imported into ArcGIS using Import Metadata.

import os
#set local variables
dir = arcpy.GetInstallInfo("desktop")["InstallDir"] + "bin" 
fgdcTXT = "c:/data/fgdcInText.txt"
fgdcXML = "c:/data/fgdcOutXML.xml"
runCmd = "mp.exe " + fgdcTXT + " -x " + fgdcXML
os.chdir(dir)
os.system(runCmd)

While the USGS MP Metadata Translator tool uses mp to perform conversions, it only accepts information in XML format; the Source Metadata parameter must be either an ArcGIS item or a stand-alone metadata XML file. For example, if a text file is provided, the text file's metadata will be extracted from the item and used as the input to the mp utility. The only way to run mp with either a text or SGML file as input from ArcGIS is to run the tool from Python as illustrated above.

The mp utility does not accept metadata in HTML format as input. HTML metadata makes the information easier for a person to read in a web browser. However, it is very difficult for a software program to separate text from HTML code and determine what text defines a metadata element and what text is that metadata element's value.

However, if your HTML metadata was created by mp, it may be possible to convert the information back into well-formatted text using other utilities provided by USGS that are not available with ArcGIS for Desktop. The well-formatted text could then be converted to XML format, as described above.

Alternatively, you can contact the organization that supplied the metadata to request it in another format that can be processed by mp or imported directly.

3/3/2014