Spatial Query

The Spatial Query is used to define a query expression based on spatial attributes and show all objects obtained when the query is applied.  A query expression is defined by a restriction clause (WHERE clause).

It is accessible through:

    Layer Explorer > Right Click over a layer name > Spatial Query...
or
    Layer > Spatial Query...

Follow the steps bellow to define/execute the spatial query:


CRITERIA FRAME
  1. Input Layer - Select the input layer (should be visualized in the Map Display).
  2. Criteria - Defines a restriction based on spatial attributes:
    • Geometry Property - usually it is already selected
    • Operator (st_intersects, st_disjoints, st_touches, st_contains, st_union, st_crosses...)
    • Layer - select the layer to be confronted with the restriction defined.
    • Use Selected Objects - check this option if the goal is to apply the restriction only over the selected objects in the layer displayed. 
  3. Click on add to transform this criteria involving geometry property into a restriction. 
  4. Define another criteria  and add to this one if it is logically acceptable.  Check the example at the end.
RESTRICTION FRAME: here it is possible to check the restrictions, remove one line or all of them.
  1. Click on remove to clear only  one line. 
  2. Click on clear_all to clear all restriction expression and start again.
LAYER SELECTION FRAME
  1. Add -  it adds the query result to the ones already selected and shows them all.
  2. New - it removes the previously selected items and shows only the new ones selected by this query. 
  3. None - it clear previoulsy selected items from the Map Display and prepares for a new query.
  4. Apply -  apply the query restriction after selecting one of the options(add, new) and check the result in the Map Display.
QUERY LAYER querylayer
  1. Name - it shows the layer name
  2. Create Layer - press here to create a Query Layer (a special kind of layer will appear into the Layer Explorer with the same name). 
  3. Close this interface and go to the Layer Explorer to visualize the Query Layer created.
Alternatively, it is possible to create a new real Layer with the selected objects (instead of a Query Layer generated above).

Follow the steps below to generate a real new Layer:
  1. Close - keep the selected objects on the Map Display and press close.
  2. Go to the Layer Explorer -> Right Click over the layer name
  3. Choose: Save Selected Objects...
  4. Choose a new name to the Layer.
  5. The new layer will have only the selected objects.
Example: Suppose you want to select all the Municipality  touching the two ones selected in the Map Display.
       
       Map Display showing the two municipalities selected (the query will use the option Use Selected objects)
selected_obj

     Defining - Spatial Query
Spatial Query

    Restriction generated
restriction

     Resulting Query on Map Display: it shows all objects touching the two municipalities selected as input
result