My goal is to merge all shapefiles in the same folder and outputting them as a gml with name of the folder.

So it looks like this:

  • Main Dir
    • Set1
      • roads.shp
      • buildings.shp
    • Set 2
      • roads.shp
      • ...

I managed to merge the files together on this way:

Using the Shapefile Reader and setting the input to a folder with subdirectories. Then, using the FilenamePartExtractor transformer I extract the name of the folder (set1/set2/..).

Then I write to GML with the name of the folder and fanning out the GML with this name as input. The output is a file without extension, but with the correct name.

Changing the filetype to .gml confirms they have merged succesfully. But why is it not automatically writing as .gml in FME?

nb. it does output a correct .xsd file.

My navigator in FME: FME Navigator settings and parameters

And the output in my \Testdat_GML_Output\ folder: Output folder


So I think what you need here is to use both a dataset fanout and what we call (or used to call) a feature type fanout.

So for the dataset fanout you would set Expression = @value(_dirname).gml (which is what you have).

But then in the feature type (the object on the right-hand side of the canvas) you would need to set the output layer to be the _rootname:

enter image description here

Then you'll get set1.gml with layers called roads and buildings, set2.gml with layers called roads and buildings, etc, etc

I made up a workspace that demonstrates how to do that. You can download it from Dropbox. Ignore the data itself (it's just multiple copies of the same file, renamed each time).

Here's what I start with:

enter image description here

Here's what I end with:

enter image description here

  • Thanks Mark, with some minor altercations it worked! Only issue still is everything becomes a "multi"-feature type. So point becomes multipoint, etc.
    – B.Quaink
    Feb 22 '18 at 10:20
  • That could be the source data being that type. Try putting a Deaggregator transformer in the workspace and see if that helps. Feb 22 '18 at 15:33

By editing the Fanout Expression and setting the expression in the text editor as:


It worked in the end.

enter image description here

The writer is not correct, and the data does not convert correctly. But the filename is correct.

  • Yes, just adding .gml to the expression will give you what you need (FME just doesn't add that by default to a fanout expression). But you say the writer is not correct and the data not converted correctly. In what way? Feb 21 '18 at 14:49
  • During the merging of shapefiles the seperate shapefiles all become merged in one point file. Previously, when I loaded the GML in QGIS again, the different shapefiles are still seperate. Now they all become one and I lose a lot of data.
    – B.Quaink
    Feb 21 '18 at 16:22

The Dataset Fanout works differently for file-based and folder-based formats. In your case GML is a file-based format so setting the extension (.gml) in the fanout expression is mandatory.

For folder-based formats (e.g. Shapefile) FME it would create several folders instead of several files. However FME can't know whether a format is folder-based or file-based in advance. For example, if you set a .zip extension in the fanout expression when fanning out shapefiles, you would create several .zip-files instead of folders, i.e. it would work as a file-based format. I understand that's why FME doesn't automatically set the file extension.

Maybe the documentation is clearer: https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Workbench/Workbench/Setting_Dataset_Fanout_Properties.htm

  • My problem then is that I can't use an expression that takes the value of the directory path and concatenates ". gml" to it. It doesn't seem possible to do something like "@Value(_dirpath) + .gml"
    – B.Quaink
    Feb 21 '18 at 12:43
  • Apparently, this did make it work when I edited in the text editor. I'll answer my own question.
    – B.Quaink
    Feb 21 '18 at 12:53
  • I'm glad it did. Yes, you can freely edit the Fanout Expression in the Text Editor. You might as well do it directly in the input field, but if you choose an attribute you can't add anything to its name. Writing @Value(attribute_name) instead would let you use the input field as well.
    – fgiron
    Feb 21 '18 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.