Skip to content Skip to main navigation Skip to footer

Spatial Selection examples

>>> Open our test map in Map Viewer to perform spatial selection following our tutorials

Table of Contents

Important notes:

  • Spatial selection only works with database layers, not with files. If you want to perform spatial queries please import files you need into the database first. 
  • Make sure that the multigeometry type is exploded into basic geometry.
  • If you are going to perform spatial selection in two or more different layers, make sure they are in the same projection! Learn how to change the projection of a layer in GIS Cloud here.

Example 1. 

Select town with a population of 5000.

  1. Click Feature tab and Spatial Selection icon.
  2. Select table cities and column number.
  3. Write =5000
  4. Click Select.

Example 2. 

Select town with the name Andorra la Vella.

  1. Select layer area and column name.
  2. Write (don’t copy and paste) =’Andorra la Vella’.
  3. Click Select.

Note: Make sure that you put single quotes (i.e., ’giscloud’) for String (text) attributes. Attributes are case sensitive!

Example 3. 

Select counties that belong to the ‘U’ zone and have an area less then 0.012511.

  1. Select layer area and column zone.
  2. Write (don’t copy and paste) =’U’.
  3. Write AND operator.
  4. Select layer area and column shape_area.
  5. Write <0.013
  6. Click Select.

Example 4. 

Select both primary and secondary routes.

  1. Select layer roads and column route.
  2. Write (don’t copy and paste) =’Primary Route’.
  3. Write OR operator.
  4. Again select layer roads and column route.
  5. Write (don’t copy and paste) =’Secondary Route’.
  6. Click Select.

Example 5. 

Select towns inside Canillo county.

  1. Select ST_Within() operator.
  2. Select layer cities and wkb_geometry column.
    • Note: to add another table click “+” button.
  3. Select layer area and column wkb_geometry.
    Query ST_Within(and_cities.wkb_geometry,and_adm1.wkb_geometry) will select all point features within all polygon features. We want to specify county (polygon) with name (attribute) ‘Canillo’:
  4. Write AND operator.
  5. Select area and name column.
  6. Write (don’t copy and paste) =’Canillo’.
  7. Click Select.

Note: wkb_geometry field has information about geometry in the binary form.

Example 6. 

Select roads that intersect Andorra la Vella county.

  1. Select or write St_Intersects().
  2. Select layer roads and column wkb_geometry.
  3. Click + to add another table.
  4. Select layer area and column wkb_geometry.
  5. Write operator AND.
  6. Select layer area and column name.
  7. Write (don’t copy and paste) =’Andorra la Vella’.
  8. Click Select.

Here is a map with the spatial selection examples results:

Time&Date selection

To perform a spatial query based on a date/time field, follow these instructions:

  1. Open the Feature tab in Map Editor.
  2. Press Spatial Selection
  3. Choose the table (layer) and the column you want to perform the selection on.
  4. Write the selection condition.

Important notes!

When writing selection conditions, the date should be written in the UTC format, not local time. 

Also, it should be written without seconds, AM/PM and time zone information.

Allowed operators for Time and Date selections are:

  • = equal
  • <> not equal
  • < less than
  • <= less than or equal to
  • >= greater than or equal to
  • > greater than
  • AND operator

Examples

The selection process is the same for all date and time columns in GIS Cloud. In these examples, we will be selecting features from the CREATED column in the time zone GMT/UTC +2.

The CREATED column is an automatically populated field in GIS Cloud that fills out when a new feature is created on the map. Learn more about date and time fields here.

1. Select features created from 15th of July 2020 at 12:00 PM (local time) until now in the time zone GMT+2

Time string from the Datagrid (local time): ‘07/15/2020 12:00:02 PM’

The string you should write in the condition (UTC): ‘07/15/2020 10:00’

Since we would like to choose features created from the specific date, we only need one operator:  >= greater than or equal to.

This is how the condition box should look like:

 graffiti_locations.__created>=’07/15/2020 10:00′ 

2. Select features created between 15th of July 2020 at 12:00 PM and 25th of July 2020 at 12:00 PM in the time zone GMT+2

Time strings from the Datagrid (local time): ‘07/15/2020 12:00:02 PM’, ’07/25/2020 12:00:02 PM’

The strings you should write in the condition (UTC): ‘07/15/2020 10:00’, ’07/25/2020 10:00′

Since we need would like to choose features created between two dates, we need three operators: 

  • < less than
  • > greater than 
  • operator AND

This is how the coondition box should look like:

 graffiti_locations.__created>’07/15/2020 10:00′ AND graffiti_locations.__created<’07/25/2020 10:00′

3. Select features created at midnight (local time)

Time string from the Datagrid (local time): ‘07/15/2020 00:00:01 AM’

The string you should write in the condition (UTC): ‘07/14/2020 22:00’

Since we would like to choose features created exactly at midnight, we only need one operator: equal.

This is how the condition box should look like:

 graffiti_locations.__created=’07/14/2020 22:00′ 

Was This Article Helpful?