Set up an extraction using FME Form (desktop)
Info
This tutorial uses the extraction plugin FME Form (Version 2) which allows unlimited parameters length, thus allowing request with precise geometries like municipalities boundary.
To follow along with this tutorial, download the sample script and data available here. Either by cloning the repo :
git clone https://github.com/asit-asso/extract-samples.git
Or downloading a ZIP archive with the following link : https://github.com/asit-asso/extract-samples/archive/refs/heads/main.zip
Set up the FME workspace
-
In the downloaded folder, go to the subfolder
fmeand open up thesample-script-FME2024.fmwFME workspace. -
The workspace uses a
creatoras a starting point. -
The
FME Form (Version 2)plugin sends all request parameters in aGeoJSONfile. The latter is given as a CLI argument when running the workspace where the key is--parametersFileand the value is the path of theGeoJSONfile.To tell FME to use this argument, we need to create a User Parameter :
Under
User Parameters, create a newFile/Folder/URLparameter. The identifier must beparametersFile. For convenience, you can allocate a default value$(FME_MF_DIR)\parameters.jsonto the parameter. Thus, when run inside FME, the default value is taken and a local GeoJSON file is used. But when run by Extract, theparametersFilewill be overridden by the CLI argument and the GeoJSON from Extract will be used.Warning
If you run the workspace with the local
parameters.jsonfile given. You must adapt theFolderOutvalue where exported data are saved. By default, it's a windows path :C:\\extract\\orders\\123456\\folderout
Tip
The input and output folders of the request are also passed on the command line, as
--FolderInand--FolderOut:path/to/fme.exe path/to/script.fmw --parametersFile path/to/parameters.json --FolderIn path/to/folderIn --FolderOut path/to/folderOutDeclare them as
User ParametersnamedFolderInandFolderOutto use them in the workspace before theGeoJSONfile is read. TheGeoJSONfile itself is unchanged: it still carriesFolderOutamong its attributes. -
Then we need to read the
GeoJSONfile with aFeatureReader. The format isGeoJSONand the dataset is the$(parametersFile)parameter. The feature of theGeoJSONfile is the request perimeter and can be use to extract or clip data. All other attributes are the request parameters.
-
Before reading your actual data, you can set global variables from the GeoJSON attributes like the FolderOut (to know where to save the output data), the desired Format and CRS using a
VariableSettertransformer. Thus, it will be possible to use them later after reading your business data.
-
Then you can read your business data with a
FeatureReadertransformer. In our example, we use the feature from the GeoJSON parameters file (request's perimeter) to read only the data that intersect with it.
-
Once your data are read, you can retrieve the previously set variables to know for example in which format and CRS the client wants the data.

-
Reproject the data accordingly and save them in the given format. Remember, the data must be saved in the
FolderOutparameter given in theGeoJSONfile.
Connect the workspace to Extract
-
In Extract, create a new or use an existing process (see processes).
-
Drag and drop the task plugin
Extraction FME Form (Version 2)into the process task list. -
In the field
Chemin du workspace FME, type the path where your FME workspace is. In the fieldChemin du programme FME (fme.exe), type the path where your FME executable is. In the fieldNombre de fme.exe lancés par ce workspace (défaut = 1, max = 8), type the number of FME executable needed in parallel for your workspace (for our example, only one is needed).
-
To test the extraction, you can link this process to viageo (see Connect Extract to viageo.ch). With our example, the linked resource can be orderable over the entire Switzerland in the following format :
shapefile,geopackage,GeoJSONandDXF. -
Finally, you can order the linked product on viageo, Extract will retrieve the request and run the FME workspace with all request parameters carried out in the GeoJSON parameters file.
Gracefully handle extractions that return no data
By default, when no data is outputted from the extraction, the request in Extract fails because it cannot export data back the third-part service (e.g. viageo.ch). In the FME Form Extraction (Version 2) plugin, The "Cancel the processing when no data is found" option allows a request to end gracefully when the extraction returns no data. If the option is enabled, the plugin will search for the marker noDataForExtract in the logs outputted by FME. If the marker is found, the request is canceled and the final client is notified with the given remark (mandatory). Any plugin after that will be skipped and any existing remark prior to that will be overridden.
In FME, you can use a NoFeatureTester transformer to test if no data is extracted and a Terminator transformer to terminate the process with a failing exit code and to output the noDataForExtract marker to the logs :
