Friday, October 30, 2009

Flagging intersection points between 2 features with FME

It seems to be easier to fix rather than flag unbroken intersection points between two feature layers. It took me a little while longer to flag the unbroken intersection points using FME transformers. The screenshot below shows two shape file layers - lakes (blue color fill) and rivers (red). I wanted to flag the intersecting points between the lake polygons and the river lines.

I did the following.

Define the two source datasets
  1. Start up FME Workbench. Choose Create a blank workspace.

  2. Select Source Data > Add Dataset.

    The Add Source Dataset dialog appears.
  3. In the Format field, choose ESRI Shape. In the Dataset field, click the browse [...] button.

  4. Select both the lake.shp and river.shp files. Click Open.

    The Add Source Dataset may look like this.

  5. Click OK.

    The Select Feature Types dialog box appears.

  6. Click OK.

    The two selected shape files are added to the workspace.

Define the destination dataset
  1. Select Destination Dataset > Add Dataset.

  2. In the Format field, select ESRI Shape. In the Dataset field, define the output folder e.g. C:\temp\out\.

    The Add Destination Dataset dialog box may look like this.
  3. Click OK.

    The message below appears.

  4. Click Yes.

    The Feature Type Properties dialog box appears.

  5. In the Feature Type Name field, type in intersect_flag. In the Allowed Geometries, choose shape_point.

    The Feature Type Properties dialog box may look like this.

  6. Click User Attributes tab.

  7. Define an attribute ID with Data Type number and Width 2.

    The Feature Type Properties dialog box may look like this.

    Note: id will simply be a counter storing running numbers of flags.

  8. Click OK.

    The source and destination datasets appear on the workspace.
Add in the transformers and define the flow
  1. Drag and drop the following transformers onto the workspace:
    1. Intersector
    2. Coordinate Fetcher (twice)
    3. Geometry Remover (twice)
    4. Aggregator
    5. Tester
    6. 2DPointAdder
    7. Counter

  2. Connect the source and destination datasets with the transformers as shown in the figure below.

  3. Open up the first Coordinate Fetcher transformer's properties.

    Note 1: Index 0 means fetch the first coordinate.
    Note 2: After the Intersector transformer has done its job, the output features are broken up at the point of intersections. The intersection points must therefore be at either ends.

  4. Open up the second Coordinate Fetcher transformer's properties.

  5. In the Index field, type in -1.

    Note: -1 means fetch the last coordinate.

  6. Open up the Aggregator transformer's parameters.

  7. In the Group By field, browse and select the fields or type in the string _x _y.

  8. In the Count Attribute (Optional) field, type in _count.

  9. Open up the Tester transformer's parameters.

  10. Define the test _count > 2 as shown above.

  11. In the Pass Criteria field, choose One test must pass.

    Note: At the intersection points, there must be more than two points. Anything less is either free end points or singly connected points. 

  12. Open the 2DPointAdder transformer's parameters.

  13. In the X Value field, choose _x. In the Y Value field, choose _y.

  14. Open up the Counter transformer's parameters.

  15. In the Count Output Attribute field, type in id. In the Count Start field, type in 1.

    Note: the Count Output Attribute field should be the same name as the destination dataset's attribute field.

  16. Run the translation.

    The intersection points are flagged as numbered points as shown in the screen shot below.

Note that this Intersector transformer method works based on line work intersection only. If the line work sits entirely within the area polygons, there would be no line intersection and therefore no flags.


pw said...


Would like to say, your tutorial has been very helpful, so thank you for your effort.

I would like to ask, is there a method to identify the intersection points of only those between the two shape files, and not the intersection points of those found with just one shape file.

Thanks .

d0min0c said...

Hi pw, unfortunately the Intersector transformer doesn't differentiate between the two shape files. An alternative workbench flow would need to be worked out to do what you want.

Related Posts with Thumbnails