FME Version
Files
-
- 800 KB
- Download
Introduction
The Geometry Parameter in FME Flow (formerly FME Server) allows users to draw an area of interest on a map and then have that area inputted into a workspace. This functionality is first set up in FME Workbench with a combination of the Geometry published parameter and the GeometryReplacer transformer, then in FME Flow the user can access the map anywhere you can see published parameters (Run Workspace, FME Apps, etc.).
Note: The Geometry Parameter was first introduced in FME 2020.0, but this tutorial is using screenshots for 2023.1. In previous versions, it was also referred to as the Geometry Picker.
Step-by-Step Instructions
In this scenario, we want to create a workspace where the construction company can draw on a map where they will be working. Then, a 100m buffer surrounding their construction area will be set and notify the residents of the neighboring houses.
1. Open FME Workbench
Open a blank workspace in FME Workbench. Add a Creator transformer then add a FeatureReader. Connect the Creator to the FeatureReader. In the FeatureReader parameters, set the Format to Esri Geodatabase (File Geodb Open API) and set the dataset to Addresses.gdb or addresssesgdb.zip if you leave the downloaded file zipped.
For Feature Types to Read, click on the ellipsis, and select PostalAddress. Click OK twice to confirm the parameters.
2. Create Geometry Published Parameter
In the Navigator window, right-click on User Parameters, then select Manage User Parameters.
In the User Parameters dialog, add a new Geometry parameter from the green plus sign drop-down.
Then enter the following properties, click OK once configured:
- Parameter Identifier: GEOM_COORDS
-
Prompt: Enabled
- Prompt: Select construction area:
- Published: Enabled
- Required: Enabled
- Disable Attribute Assignment: Enabled
-
Expand Geometry Configuration:
- Geometry Encoding: GeoJSON
- Geometry Types: Box, Polygon, Line
-
Specify initial bounds for map display: Enabled
- Top (-90..90): 49.2548
- Left (-180..180): -123.244
- Bottom (-90..90): 49.3034
- Right (-180..180): -123.071
- Conditional Visibility: Disabled
- Default Value: <Leave blank>
Note: In FME 2022.0+ the dialog box inside of FME Flow will inherit the text listed for Prompt in the Geometry Parameter. In older versions, this dialog box will have the title Geometry Picker.
If you are unsure of your specific initial bounds, see the How to Determine Map Bounds with FME section at the bottom of this article.
3. Add GeometryReplacer
Now that we have set up the geometry published parameter, we need to use it within the workflow. Add a GeometryReplacer transformer to the canvas and connect it to the Creator.
4. Modify the GeometryReplacer Parameters
Open the parameters for the GeometryReplacer. Set the Geometry Encoding to GeoJSON and then set the Geometry Source to the GEOM_COORDS published parameter. The geometry published parameter works with both GeoJSON and OGC Well Known Text encoding.
5. Set Coordinates and Reproject
We will want to ensure that our data is in LL84 as this is what the geometry published parameter accepts as values.
Add a CoordinateSystemSetter transformer to the canvas and connect it to the GeometryReplacer. In the parameters, set the Coordinate System to LL84.
We also need to ensure our PostalAddress points are in LL84. Add a Reprojector to the canvas and connect it to the PostalAddress output port on the FeatureReader. Set the Destination Coordinate System to LL84.
Your workflow should look like this once both the coordinates are set:
6. Buffer Area
Let's add a 100-meter buffer to select which neighboring residents to notify. Add a Bufferer transformer to the canvas and connect it to the CoordinateSystemSetter. In the parameters, set the Buffer Distance to 100 and set the Buffer Distance Units to Meters.
7. Clip to Buffer
Now we need to clip our data to the buffered radius of our construction area and our PostalAddress points. Add a Clipper to the canvas, connect the Clipper input port to the Bufferer, and the Clippee input port to the Reprojector.
8. Clean up Attributes
One final step before we can write out our data is to clean up the attributes. Add an AttributeKeeper to the canvas and connect it to the Inside output port on the Clipper.
In the parameters, for Attributes to Keep select:
- OWNERNM1
- PSTLADDRESS
- PSTLCITY
- PSTLPROV
- POSTALCODE
You can copy and paste the following into the Attributes to Keep parameter instead of manually selecting them, if desired:
OWNERNM1,POSTALCODE,PSTLADDRESS,PSTLCITY,PSTLPROV
9. Write Out Data
Now we can write out the data to a Microsoft Excel file. Add a Microsoft Excel Writer to the canvas and name the dataset NotifyAddresses.xlsx. Set the Sheet Definition to Automation and click OK.
In the Feature Type dialog, set the Sheet Name to NotifyList and click OK.
Connect the NotifyList writer feature type to the AttributeKeeper transformer. Save your workspace.
10. Publish to FME Flow
With the workspace complete, we can now publish to FME Flow. Save the workspace as ConstructionNotifier.fmw. Now, click on the Publish button on the toolbar or go to File > Publish to FME Flow. Select your FME Flow connection, then create a new repository called GeometryParameter. Ensure that Upload data files is enabled then click Next.
Select Data Download and Job Submitter as the Services, then click Publish.
11. Run Workspace in FME Flow
Log into FME Flow and click on Run Workspace.
Select GeometryParameter as the Repository, select the ConstructionNotifier.fmw workspace, and set the Service to Data Download.
For Published Parameters, you should see the Select construction area parameter. Click on the map icon to select the area.
When you click on the map icon, the Geometry Parameter dialog will appear, which will have a map of the area set up in the published parameter, as well as options along the top to determine which geometry type you wish to use for your selection. If you would like to change the background map, see How to Set a Custom Basemap.
Note: In older versions, the title of this dialog will be Geometry Picker, in 2022.0+ the dialog will inherit the Prompt created in the Geometry Parameter in FME Workbench.
Zoom into the area of interest using either your mouse scroll wheel or the plus sign at the top. For this example, we will zoom into downtown Vancouver and use the polygon tool to pick a small area of buildings.
Note: For this workspace to run correctly, buildings with addresses need to be selected. If an area is selected without an address the workspace won’t write out any data.
To close off an area in a polygon, click on the starting point. Once the area is selected, click Confirm. GeoJSON coordinates will now be available in the Select Construction area text box. These coordinates can be put into the published parameter within FME Workbench for testing the workspace.
Once the map area has been selected, click Run to run the workspace in FME Flow.
When the workspace has finished running, click on the Data Download URL to download the data. Extract and open the data in Microsoft Excel or FME Data Inspector. This list can then be used to send letters to the residents affected by the construction.
Note: If you are getting 0 features being written out, try another area as the workspace won’t work if an area with no address points is selected.
How to Determine Map Bounds with FME
If you are unsure of the coordinates for the map bounds, you can use the Geometry Parameter to acquire them.
1. Setup Initial Geometry Published Parameter
Create a Geometry published parameter, but you can leave all the properties as the default.
2. Publish to FME Flow
Ensure there is a Creator on the canvas, then publish to FME Flow.
3. Open the Geometry Parameter
In FME Flow, go to the Run Workspace page, then browse to the location where you published the workspace. Click on the map icon next to Select Geometry (which is the default text).
Then in the Select Geometry popup, use the search function (available in 2021.2+) or use the hand tool to navigate to your wide area of interest. Now use the Line tool to draw a line from the top left corner to the bottom right. Then click Confirm.
Then copy the coordinates from the text box, into the Geometry published parameter in FME Workbench.
How to Set a Custom Basemap
By default, the basemap in the Geometry Parameter is set to OpenStreetMap’s standard tile layer. The basemap can be changed by providing a different Web Map Tiles Service (WMTS). The default coordinate system for displaying basemaps is EPSG:3857. Geometries drawn on the Geometry Parameter are still in EPSG:4326.
1. Copy the WMTS URL.
Copy the basemap WMTS URL for the service that you wish to display. The Geometry Parameter is limited to XYZ-formatted tile layer links which generally looks like this:
https://<service_url>/{z}/{x}/{y}
Depending on the service configuration, a WMTS template URL may follow the OGC specification which uses different variable names for the tile column, row and matrix. These URLs can be converted to the XYZ standard. For example, an Esri MapServer and ImageServer template URL is usable in the Geometry Parameter after being reformatted to the following styles:
https://services.arcgisonline.com/arcgis/rest/services/<service_name>/<ImageOrMapServer>/WMTS/tile/1.0.0/<layer_name>/<style>/<tileMatrixSet>/{z}/{y}/{x} https://portal_host/server/rest/services/Hosted/<service_name>/<ImageOrMapServer>/WMTS/tile/1.0.0/<layer_name>/<style>/<tileMatrixSet>/{z}/{y}/{x}
A list of public tile layer services includes the following:
Tile Service | URL |
---|---|
Google Maps (Roads) | https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z} |
Google Maps (Hybrid) | https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z} |
Esri (Standard) | https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x} |
Esri (Satellite) | https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x} |
Esri (Topographic) | http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x} |
Note: The default OpenStreetMap URL has an additional {s} variable at the beginning. This variable is meant to randomize requests to the different OSM tile servers (a, b, c) and is not required for most other tile service URLs.
2. Paste the URL into the Geometry Parameter Settings
In the Geometry Parameter, click the Map Configuration button on the top right. In the Basemap URL parameter, replace the existing link with your WMTS URL and click Save or Change Map URL (for 2021.0 and 2021.1).
In certain cases, a WMTS may not have tiles around the entire Earth. Before switching the WMTS URL, make sure you pan the map view to a location where you know the tiles will display, or else the map will turn grey and you may not be able to find your tiles!
If the background map turns grey and fails to display, double-check that your URL is correct and that it’s working in a different client. If the map still fails to load, try zooming in or out since the WMTS may not have tiles at the zoom level you were using just before switching the URL.
3. (Optional) Reset the Geometry Parameter to the Default Basemap
In the Geometry Parameter’s settings, click the Reset button to change the basemap URL back to the default OpenStreetMap tile server.
Search for Locations in the Map
New in FME Server 2021.2+ is the ability to search for locations in the Geometry Parameter map. The Search function is powered by the OpenStreetMap Nominatim tool for reverse geocoding names and addresses based on OSM data. Various third-party providers offer their own hosted Nominatim APIs for larger processing needs, and it’s possible to configure the Geometry Parameter to use these APIs instead. For more information on Nominatim and alternate providers, please refer to this wiki by OpenStreetMap.
To change the Nominatim, go into the Geometry Parameter’s map configuration settings. In the Nominatim URL parameter, paste your own provider’s URL. To change the Nominatim back to the default OpenStreetMap URL, click Reset and Save.
Additional Resources
Geometry Published Parameter Documentation
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.