Point in Polygon Subflow

This procedure describes how to create a subflow using the Query Spatial Data stage to deterimine if a point is located within a given polygon.

This subflow takes as the source an x and y and creates a point geometry using Spatial Calculator's Create Point operation. The resulting geometry is the input for the Query Spatial Data stage which is then output to an output sink.

This procedure is one way to find points in a polygon. An alternative is the Point in Polygon stage that uses a Centrus database. Both operations are discussed in the "Point In Polygon Best Practices" topic in the Development section of the Spectrum Spatial Guide.

To create a point in polygon subflow:

  1. In Enterprise Designer, choose New > Dataflow > Subflow from the File menu or New > Subflow from the Task pane.

    For more information about creating subflows, see the Dataflow Designer's Guide from the Help menu.

  2. Drag an Input icon onto the canvas and double-click it to display the Options dialog.
  3. Click the Add button to display the Add Custom field dialog. Click Add and provide the field name 'x' and the type as double. Click OK.
  4. Repeat Step 3 to add a field 'y' of type double. Click OK to leave the Input Options dialog.
  5. From the Spatial Stages section in the Palette, drag Spatial Calculator onto the design canvas. Click the solid black triangle on the right side of the Input stage (the output port) and drag it to the left side of the Spatial Calculator stage to create a channel.
  6. Double-click on Spatial Calculator to display the Options dialog. Choose Create Point Geometry from the list of operations. Change the coordinate system if necessary. Click OK. Rename the Spatial Calculator to Create Point so you can remember what it does.
  7. Drag the Query Spatial Data stage onto the canvas. Connect the output port of the Create Point operation to the input port of the Query Spatial Data stage.
  8. Double-click on the Query Spatial Data stage to display the Options dialog. Create the MISQL statement in the box provided and click Verify.

    Here is an example statement. Modify the field and named table to match your data.

    select STATE from "/Samples/NamedTables/USA" where Obj contains ${Geometry}
  9. Drag an Output sink onto the canvas. Connect the output port of the Query Spatial Data stage to the input port of the Output sink.
  10. Double-click on the Output sink and check the field you wish to expose. In our example, check the State field. Click OK.
  11. Save the subflow. To expose the subflow for use in a dataflow, choose File Expose/Unexpose and Save or click the Expose/Unexpose and Save button. The subflow displays in the User-Defined Stages folder.

    The subflow is now ready to incorporate into a Point in Polygon dataflow.