Spatial Query Example

This example uses the road, lake, and administrative division layers in the sample data China.udb data source to query:

  • Which lakes are contained within Hunan Province;
  • Which highways passing through Hunan Province have road codes of G320.

Detailed steps are as follows:

  1. Open the sample data China.udb data source in the current workspace.
  2. Create a new map and add the Provinces_R, Lake_R, and ProvinceRoad_L datasets to it.
  3. Select the Hunan Province administrative boundary polygon in the Provinces_R layer, which will serve as the search object for spatial query.
  4. Click the Spatial Query button in the Spatial Analysis tab > Query group to open the "Spatial Query" dialog.
  5. Configure spatial query conditions and attribute query conditions for target layers:
    • In the Road_L layer list, click the "Spatial Query Condition" dropdown and select "Intersect_Polyline" to query highways passing through Hunan Province;
    • Click the "..." button in the "Attribute Query Condition" column of the Road_L layer to open the SQL Expression dialog. Set the condition as: Road_L.CODE = "G320".
    • For the Lake_R layer, select "Contain_Polygon" from the "Spatial Query Condition" dropdown to query lakes within Hunan Province.
  6. Select both Road_L and Lake_R layers. Check "Browse in Attribute Table" and "Highlight in Map" under "Show Results".
  7. For the Road_L layer, enable "Save Results" and set the output dataset name to "Highways_G320_Hunan" in China.udb.

    Similarly, name the Lake_R query result dataset as "Lakes_Hunan".

  8. Click the "Query" button to execute the spatial query.
  9. Review results in both attribute table and map view. When selecting any record in the query result table, the corresponding object will be automatically located on the map, achieving linked views.
    Figure: Browsing Spatial Query Results