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.
Creating a Query
Navigate to to: Desktop → Queries → New
![](https://mae.hexagon.com/content/images/2023/11/Screenshot-2023-11-07-1105111-1.png)
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.
![](https://mae.hexagon.com/content/images/2023/11/Screenshot-2023-11-07-111600-3.png)
![](https://mae.hexagon.com/content/images/2023/11/Screenshot-2023-11-07-112432-2.png)
Example
A table with your queried information will appear in the bottom of your map window.
![](https://mae.hexagon.com/content/images/2023/11/Screenshot-2023-11-07-121806-1.png)
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.
![](https://mae.hexagon.com/content/images/2023/11/Screenshot-2023-11-07-123325.png)