Exercise | GeoDatabase Metadata |
Overall Goal | To show how an XML based web service can be used within FME |
Demonstrates | Call a web service and processing the XML response using FME's XML transformers |
This exercise will look at adding Metadata to a GeoDatabase to ensure that all of the relevant information such as linage, licensing, data currency and data accuracy is stored with the data layers.
Working with Geodatabase Metadata: Writing/Updating Metadata
Introduction
A metadata record is a file of information - usually presented as an XML document - that captures the basic characteristics of a data or information resource. Geospatial metadata are used to document geographic digital resources such as Geographic Information System (GIS) files, geospatial databases, and earth imagery.
A geospatial metadata record includes core library catalog elements such as Title, Abstract, and Publication Data; geographic elements such as Geographic Extent and Projection Information; and database elements such as Attribute Label Definitions and Attribute Domain Values.
Reading Geodatabase Metadata
Reading geodatabase metadata is triggered by setting the geodatabase reader parameter – Feature Read Mode – to 'Metadata'. When reading metadata, the reader feature types have a completely different schema than when reading features. Instead of listing user attributes, a metadata feature type lists a number of metadata fields, including geodb_metadata_string (an XML string containing the geodatabase metadata) while other format attributes store information such as dimension, spatial column, geometry, etc.
In metadata mode, only a single feature is output from the feature type. This means that to read features and metadata you need two geodatabase readers: one to get the features and one to get the metadata.
Writing Geodatabase Metadata
Writing metadata occurs when a feature of the correct type is written to the table to which the metadata applies. A metadata feature must have the correct geometry type (i.e. have the geodb_type format attribute set to ‘geodb_metadata’) and the metadata being written should be held as XML in the format attribute - 'geodb_metadata_string'. It will overwrite any previous metadata that was on the table/feature class. If multiple metadata features are written to the same table, then the final feature is used.
Note that the destination feature type (table) should be that of the geometry type (point, polyline, etc.).
Source Data
BikePaths_L (Esri Shapefile)
BikePaths_L (XML Document)
In the above images, we see a visualizations of the BikePaths_L shapefile and of a section of the BikePaths_L XML file.
Workspace Description
1. Read Source Data
Bike Path feature geometry is read from the source shapefile using the Esri Shapefile reader while Bike Path metadata is read from an XML document using the XML (Extensible Markup Language) reader. These files will provide the features and metadata for the destination feature class. When adding the XML reader, click on the parameters button and set the Configuration Type to "Feature Paths". In addition, click on the [...] button next to the Elements to Match dialog and in the resultant dialog window, check the box next to "metadata".
2. Define XML Feature as Metadata and Update
The AttributeCreator is used to create a metadata string attribute (geodb_metadata_string) that will hold the incoming XML definition contained in the xml_fragment attribute. In addition, the AttributeCreator will also be used to define the destination geodatabase format as metadata. This is done via the use of a format parameter (geodb_type) set to the value geodb_metadata.
By looking at a section of the incoming metadata, one can see that a value indicating a minimum bike path length has not been applied to the metadata.
The XMLUpdater transformer will be used to update the incoming metadata with a new value. Within the XMLUpdater parameters dialog, in the XML Document section, set the following values:
XML Input: Text or Attribute
XML Text: geodb_metadata_string
In the Updates section of the transformer, set the following values:
Update Type: Replace Contents
XML Path: /metadata/dataIdInfo/idPurp
Value Type: Plain Text
Value: Data for Bike Paths that are over 15 km long
Finally, set the Result Attribute to geodb_metadata_string.
Basically, this transformer this will take the metadata string, replace the path we chose with the new value, and write the new value back to the same attribute.
- Join Line Features and Calculate Length
There are a couple of actions we will perform on the bike route linework. The LineJoiner transformer will connect line features together. When adding the LineJoiner, open the transformer's parameter dialog and click the [...] button for the Group-By parameter. Choose PathId, PathName, and PathType as the attributes to group by. The transformer will connect the line features together in instances where they share the same ID, Name, and Type.
The LengthCalculator will calculate the length of the incoming line features. When adding the LengthCalculator, open the transformer's parameter dialog and be sure to set the Length Attribute parameter to 'PathLength'.
- Write Features and Metadata
Add the Esri Geodatabase (File Geodb Open API) writer and specify the output geodatabase to which the data will be written (i.e. VancouverCity). When prompted to select a feature type, be sure to select BikePaths_L [SHAPE]. Once added, connect the output of the XMLUpdater and LengthCalculator to the geodatabase writer. As an optional step, double-click on the geodatabase writer and, under General, rename the feature class/table name to "BikePaths". Save and run the workspace.
Completed Workspace
Results in ArcMap
CONGRATULATIONS |
The tasks above demonstrate |