How to Read and Translate all Feature Classes from Multiple Esri Geodatabases

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2018.x

Introduction

It is possible to make use of the Schema (Any Format) reader to read the feature class names out of any database and then pass these names into a FeatureReader transformer to do the actual reading. This makes it possible to translate, for example, multiple Esri file geodatabases, into some other format like shapefile without knowing exactly which feature classes are in the database.

 

Step-by-step Instructions

1. Use the Schema (Any Format) reader to read folders of Geodatabases.

In a blank workspace, add a Schema (Any Format) reader to the canvas. For the dataset, click the arrow drop-down menu and select Select Multiple Folders/Files…. to get into the Advanced File Browser.

schemareader.png

In the Schema (Any Format) reader, use the drop-down arrow to Select Multiple Folders/Files

 

In the Advanced File Browser, click on Add Folders… and then select the folder which contains all of the geodatabases you would like to read in. For this example, we will be using the Data folder which is contained in the FMEData2018 folder. Then under File/Filter type *.gdb this will select all of the files that have the geodatabase file extension. Finally, enable Subfolders so that the file browser will look through all of the subfolders contained within the Data folder.

advancedfilebrowser.png

Advanced File Browser, select the containing folder, and set the File/Filter to *.gdb and enable Subfolders

 

The Schema (Any Format) reader will read the list of feature classes in all the geodatabases in the folders and returns the names of the feature classes in an attribute called "fme_feature_type_name".

 

2. Setup the FeatureReader

Add a FeatureReader transformer to the canvas, connect it to the Schema reader and open up the parameters. In the FeatureReader parameters, set the Format to Esri Geodatabase (File Geodb Open API). For the Dataset, use the drop-down arrow to select the User Parameter SourceDataset_SCHEMA. This parameter was created by the Schema reader.

Next, for the Feature Types to Read select the fme_feature_type_name attribute using the drop-down menu. This attribute is generated by the Schema reader.

Expand the Attribute and Geometry Handling section, and then expand the <Generic> Port section. For Attributes to Expose click on the ellipsis [...] and type in fme_feature_type, this will ensure that the fme_feature_type attribute is exposed when we connect our writer to the <Generic> port.

The remainder of the FeatureReader parameters can be left as the default. In addition, the FeatureReader also returns the schema of each of these feature classes, which can be accessed by connecting to the <Schema> port.

featurereader.png

FeatureReader parameters. Set the Format, Dataset, Feature Types to Read and Attributes to Expose

 

3. Dynamic Writing

Add an Esri Shapefile writer to the canvas and select your output location. For the Shapefile Definition select Dynamic (Advanced).

schemawriter.png

For the Esri Shapefile writer, set the Shapefile Definition to Dynamic (Advanced)

 

Connect the writer to both the <Schema> and <Generic> output ports on the FeatureReader.

workspaceoverview.png

Connect the Dynamic writer to the <Schema> and <Generic> output ports on the FeatureReader

 

In the writer parameters, ensure that the Shapefile Name is set to fme_feature_type and that the Geometry is set to From Schema Definition. Finally, change the Schema Source to “Schema From Schema Feature”, uncheck any other schemas.

writerparameters.png

In the Dynamic writer parameters, set the Schema Sources to only "Schema From Schema Feature"

 

Note: If reading Multiple Geodatabases with the same schema, ensure you are not sending any duplicate Feature Type names to the Feature Reader. Otherwise, FME will continue to read the feature type again, producing duplicates. Add a DuplicateFilter before the FeatureReader set to the Feature Type name.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.