FME Version
Files
Introduction
We want to be able to update a map weekly to indicate sports field status. This workspace takes a CSV file containing field availability and combines it with a MapInfo Tab file containing park polygons in the city of Vancouver. The field status can change each week, so we want to create a workspace that reads the newest CSV file and generates the updated KML file without modifying the workspace each time. This can be done with user parameters and FME Flow (formerly FME Server).
Step-by-step Instructions
Part 1: Setup the CSV Reader with a User Parameter
We’ll need to make changes before uploading the workspace to FME Flow.
1. Open the Template File and Create a User Parameter
Download the starting workspace template and data from the Files section of this article. Open the CheckFieldStatus.fmwt in FME Workbench. Expand the CSV Reader in the Navigator Pane. Right-click the Source CSV file parameter and select “Create User Parameter”.
In the Navigator Pane, the cog wheel next to the Source CSV file name is red. This is expected because we haven’t added the CSV file; the cog will turn pink once added.
In the Add/Edit User Parameter dialog, change the Prompt to “Field Status CSV File:” and clear the Default Value. Then click OK.
The parameter we created is found under User Parameters in the Navigator pane.
2. Choose a Location for the Output KML File
Expand the OGCKML writer in the Navigator Pane. Double-click Destination Google KML File parameter.
Browse to the location where you want the output KML file written and click OK.
3. Run the Translation
To run the workspace, first, we need to ensure that “Prompt for User Parameters” is enabled so we can add the new CSV file as a User Parameter. On the top toolbar, click the drop-down next to Run. If Prompt for User Parameters does not have a checkmark next to it, click to enable it.
Once Prompt for User Parameters is enabled, click Run to run the workspace. Next, the Translation Parameters dialog will appear. In the dialog, browse to and select the weekendsportsfieldstatus.csv file. Uncheck ‘Save As User Parameter Default Values’ - we do not want to provide a default location for the user running the workspace since it may be different each time. Click Run.
4. Inspect the Data
After running the workspace, click on the FieldStatus writer to view the mini toolbar. Select the folder icon that will open the folder containing the KML data.
Double-click on the FieldStatus.kml in the file browser to open the file in Google Earth if installed. Otherwise, you can view your data in Visual Preview without the additional popup information. As you can see, the workspace added stylings so that the closed fields are red and the open fields are green. If you click on a park polygon, a popup dialog will appear with information about the status, closure notice, and last updated date.
Part 2: Publish Workspace to FME Flow
1. Create an FME Flow Connection
Return to the workspace you just created for the next step. There are two ways to publish workspaces to FME Flow. You can click on the Publish to FME Flow tool or File > Publish to FME Flow.
In the Publish to FME Flow dialog, click the drop-down next to Connection, select the FME Flow connection you wish to use, or select “Add Web Connection” and enter your FME Flow credentials. Click Next. For more detailed instructions on creating an FME Flow connection, see Publish a Workspace to FME Flow and Run It.
2. Create a New Repository
To create a new repository, click New next to Repository Name. A new dialog window will open where you can type a name and an optional description. Let’s call the new repository “Data Upload Tutorial” and add your description. Click OK.
By default, “Upload data files” is checked. Click on “Select Files” to see which files are included.
The Parks files are all from the MapInfo dataset, which our workspace needs to run. Leave those checked. Uncheck the CSV file at the bottom; we want the user to provide the CSV file for this workspace, which is why we created the user parameter at the start. Click OK until you are back to the Publish Workspace dialog. Then click Next.
3. Select Services to Register
Register for this workspace using the Data Download, Data Streaming, and Job Submitter services. This will allow a job with the workspace to be submitted on FME Flow and the resulting KML file to be downloaded or streamed to a webpage by the user. Click Publish to publish the workspace to FME Flow..
You can view the translation log in Workbench for the Publish Summary to ensure the workspace was published correctly. The translation log contains essential information, such as what resources were uploaded and which services the workspace was registered to.
The following tutorial, Data Upload with FME Flow: Direct Upload, will continue the exercise of running the workspace in FME Flow and downloading a zip file containing the data.
Data Attribution
The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.
Comments
0 comments
Please sign in to leave a comment.