span8
span4
span8
span4
Previous: Polygon Within a Distance of Selected Features| Next:Generating Slope and Aspect
In this tutorial,you will learn how to find the nearest features using point and polygon datasets.The purpose of this operation is to find the nearest feature from an object of interest based on the straight line distance between features (i.e.starting from a point of interest,such as a school in Vancouver,find the nearest park polygon feature).In order to accomplish this,you need to use the NeighborFinder transformer.The NeighborFinder is typically used to identify nearest features,features within a specified distance,or finding the closest feature in a certain direction.
In this scenario,you are interested in determining where the nearest park with washroom facilities is from the starting point,Alexander Academy.In this exercise,you will learn how to query your datasets based on attribute values and perform a simple spatial analysis using a point and polygon dataset.For an in-depth tutorial on finding nearest neighbors and calculating both the distance and bearing for multiple features,see theDetermining Nearest Neighborsarticle.
The Tester will be used to "select" a school from the dataset.
This will reveal two buttons,an ellipsis button and a drop-down list.
To find out more about duplicated transformers,see theDesktop Basic Course Manual.
Note: FME allows you to duplicate transformers that are currently on the canvas by right-clicking the transformer and selecting duplicate from the menu.Alternatively,you can select the transformer and use the shortcut CTRL+D to duplicate the selected transformer(s).So far,your workspace should look like the screenshot provided below:
The second Tester will be used to query the Parks dataset so only features with the specified attributes can be returned.You will set two test conditions that will use the Pass Criteria "All Test (AND)" - all tests must pass for the input feature to be classified as Passed.For more information on the Tester and Pass Criteria,see theTester Documentation.
Left Value | Operator | Right Value |
Washrooms | = | Y |
DogPark | = | N |
Ensure your Tester Parameters dialog matches the screenshot below then click OK to accept the changes and close the dialog.
In this case,the default parameters for the NeighborFinder work because it will find only find 1 neighbor.
Note: To correctly analyze spatial relationships,all features should be in the same coordinate system.TheReprojectormay be useful for reprojecting features within the workspace.However,in this case,both features are already in the same coordinate system.
By sorting numerically in ascending order,the nearest features will be placed at the top of the list in the attribute table.
Since you are interested in finding the nearest feature you will sort based on the _distance attribute in Numerical Ascending order.
Attribute | Alpha/Num | Order |
_distance | Numeric | Ascending |
In this case,the Sampler transformer is used to select the first record in the attribute table (i.e.the nearest feature since we just sorted by ascending order on the _distance attribute).
After running the workspace,the output of the nearest park will be displayed in the FME Data Inspector with a point on the map for Alexander Academy for reference.If you wish to save the output,you can either connect a writer to the Sampler:Sampled port or by using the Save Selected Data as in the FME Data Inspector and selecting the format that you want to save the data as (i.e.PostGIS,File Geodatabase,DWG,etc.).For more information on saving data in the FME Data Inspector,see theDocumentation.
Data used in this tutorial originates from open data made available by theCity of Vancouver,British Columbia.It contains information licensed under the Open Government License - Vancouver.
© 2019 亚搏在线Safe Software Inc |Legal