Skip to main content

Desktop Apps

Queries

Queries enable filtering of geographic objects based on specified attributive and spatial constraints. This post will explain the basics of queries in a step-by-step approach.
💡
Basically, queries allow you to get specific information about one or more geometries out of the database. Results of the query can be observed in the corresponding data window while objects are highlighted in the map.

Creating a Query

Navigate to to: Desktop → Queries → New

Besides the name indication you have to define the Query Dataset and the Display Dataset. This can either be the same or different datasets depending on your spatial question.

Example: Let's consider that you want to evaluate subway entrances within a certain radius to a specific building. In this case, the query dataset would be the one with the building geometries, because it is the start point of the query. On the contrary, the display dataset would be the one with the subway entrance geometries.

You can instantly check if the query is correct by clicking on Test Query.

Defining your query

There are two possibilities to define your Query and both contains Placeholders:

  • {Entity.IdFilter}: at runtime will be replaced with the a list of comma separated IDs which represents the objects selected on the map, e.g.:
    SELECT *, ST_Area(Geometry) as Area FROM Buildings WHERE gid in ({Entity.IdFilter})
  • {Entity.MyTextfield}: at runtime will be replaced with a textbox in which the user can provide input text to be searched, e.g.:
    SELECT ID,ZipCode, Borough, Address, OwnerName, ST_Area(Geometry) as Area, NumBldgs as "Number of Buildings", NumFloors as "Number of Floors", YearBuilt FROM tax_lots WHERE ID = {ENTITY.TaxLot}
  • you can combine multiple placeholders in one query, e.g.:
    SELECT s.id, s.name, ST_Distance(s.geometry, ST_Transform(b.geometry,2831)) as Distance FROM subway_entrances s JOIN buildings b ON ST_Intersects(s.geometry, ST_Buffer(ST_Transform(b.geometry,2831), {ENTITY.Distance})) AND b.gid IN ({ENTITY.IdFilter}) order by distance

Considering that you have added a query, you will need to set the query layer active before you select some geometries in the map. Select as many geometries as you want before you make a right click and choose your query.

Example

A table with your queried information will appear in the bottom of your map window.

You can delete a single row of your query info table by clicking on the x-icon or close the whole tab when clicking on the blue x on top. It is also possible to sort the table by clicking on the column names.

Pin a tab

The blue point icon on top of the query table enables you to save your query selection during your session. You can further start another query, which will be opened in another tab. This allows for switching between the tables.