span8
span4
span8
span4
Besides spatial relationships where the features physically intereact with each other, a common GIS requirement is to find a relationship based on the distance apart and/or to find the closest object to a specific base point.
This operation is often called "Nearest Neighbor" and in FME it is carried out using the NeighborFinder (or NeighborPairFinder) transformer.This transformer will locate the nearest neighbor (or neighbors) to a feature, and transfer their attributes (such as ID) to create a record of that neighbor.It will also add attributes to record the distance and bearing (angle) to that neighbor.
Video to come
The source datasets for this example are address point features in an Esri File Geodatabase and a set of cell phone tower locations stored in a CSV (Comma Separated) file.
This example is a simple exercise to identify the nearest tower to each residential address and to write that information back to a new address dataset.
1.Start FME Workbench.Use the Generate Workspace tool to generate a workspace.
The reader and writer data format should both be set to Esri Geodatabase (File Geodb Open API).
Select the attached Geodatabase data as the source dataset.Set the output Geodatabase to be something different such as C:\FMEOutput\NewAddresses.gdb (updating a Geodatabase content is outside the scope of this article).
When prompted, select only the PostalAddress table, not the PostcodeBoundaries table.
2.Open the properties dialog for the writer feature type.Click the User Attributes tab and add two new attributes;STATIONID (type: int) and STATIONDISTANCE (type: double):
3.Now select Readers > Add Reader from the menubar to add a reader for the cell phone dataset.
This time set the data format to CSV (Comma Separated Value).Select the attached CSV file as the source dataset.Within the same dialog, set the coordinate system to LL84
Click the Parameters button on the Add Reader dialog.Set the data type for the longitude attribute to be x_coordinate, and the data type for the latitude attribute to be y_coordinate
4.Add a Reprojector transformer connected to the CSV (cell tower) feature type.Set up the parameters to reproject the data to UTM83-10 (if you set the coordinate system in step 3, FME will already know what to reproject from).
5.Add a NeighborFinder transformer.Connect the postal address feature type to the NeighborFinder:Base port.连接Reprojector: Reprojected输出端口 the NeighborFinder:Candidate port:
6.Open the NeighborFinder parameters dialog.We only need to find the 1 nearest feature, so set the Number of Neighbors to Find parameter to 1.Set the Maximum Distance parameter to 500.
7.Map StationID to STATIONID on the writer, and _distance to STATIONDISTANCE:
You can manually map the attributes (as above) or use an AttributeManager transformer.
8.Run the translation.Inspect the output.Each address should now include attributes that record the nearest cell phone tower (STATIONID) and the distance to that tower (STATIONDISTANCE).
Point in Polygon Calculations with the PointOnAreaOverlayer
Shortest Route Calculations with the ShortestPathFinder
Determining Spatial Relationships
Coordinate Systems and Measurements with the Reprojector
Distance Measurements with the LengthCalculator
Buffering features for Spatial Relationship Analysis
© 2020 Safe Software Inc |Legal