TQL tutorial: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 52: | Line 52: | ||
===Statements=== | ===Statements=== | ||
To create queries effectively, some knowledge of which statements are available is important. | To create queries effectively, some knowledge of which statements are available is important. Construct the following queries and see the results: | ||
; SELECT_NAME | ; SELECT_NAME | ||
Line 130: | Line 130: | ||
==Grid queries== | ==Grid queries== | ||
Queries can be used to consult grid data as well. [[Grid Overlay|Spatial calculation]]s can produce produce results which allow for a general estimation of outcomes, but of which the exact values may be more difficult to read. For example, a [[Heat Stress Overlay]] may compute the location of hot or cool locations, but it may be difficult to compare optically how two different locations compare to one another. | |||
To experiment with queries for grid calculation results, a [[Grid Overlay]] should be present in the [[Project]]. A [[Heat Stress Overlay]] is a good Overlay to experiment with. | |||
Ensure a [[Heat Stress Overlay]] is present in the [[Project]] | |||
{{editor location|Overlays|dropdown=Environmental|Heat Overlay}} | |||
If necessary, ensure the [[Heat Stress Overlay]] is recalculated as well. | |||
{{editor location|update}} | |||
===Grid clauses=== | |||
Construct the following queries and see the results. | |||
; WHERE_GRID_IS_... | |||
: The grid to use. Whenever a query is constructed to consult data related to a query, the consulted grid must be specified as well. | |||
; WHERE_TIMEFRAME_IS_... | |||
: The [[Timeframe]] of the grid to use. When absent, the last [[Timeframe]] of the [[Grid Overlay]] is used. | |||
; WHERE_MINGRIDVALUE_IS_... | |||
: Consulting only grid cells the value of which is at least the specified value. (Inclusive, so a cell with the exact value is included.) | |||
; WHERE_MAXGRIDVALUE_IS_... | |||
: Consulting only grid cells the value of which is at most the specified value. (Exclusive, so a cell with the exact value is excluded.) | |||
Create and execute the following query, with the [[Heat Stress Overlay]] selected for the GRID clause: {{code|1=SELECT_LANDSIZE_WHERE_MINGRIDVALUE_IS_35.0_AND_MAXGRIDVALUE_IS_45.0_AND_GRID_IS_...}} | |||
The result is the surface area in the [[Project area]] which has calculated temperatures in the range of 35°C to 45°C. | |||
===Grid statements=== | |||
Construct the following queries and see the results. | |||
; SELECT_GRIDAVG_... | |||
: The average value of grid values. | |||
Create and execute the following query, with the [[Heat Stress Overlay]] selected for the GRID clause: {{code|1=SELECT_GRIDAVG_WHERE_GRID_IS_...}} | |||
The result is the average temperature in the [[Project area]]. | |||
{{header|level=3|color=#c45911|Assignments}} | {{header|level=3|color=#c45911|Assignments}} | ||
# | # Create a query to obtain the average temperature in a specific neighborhood. | ||
# Create a query to obtain the surface area of roads in a specific neighborhood with a temperature of at most 40 degrees. | |||
==Complex and combined queries== | ==Complex and combined queries== |
Revision as of 15:09, 7 December 2023
Redirect to:
Prerequisites
The following prerequisites should be met before starting this tutorial:
- This tutorial relies on base knowledge about the editor interface. If you have not yet followed the tutorials related to those subjects please do so first.
- This tutorial can be followed with any project of any arbitrary location, preferable in an urban environment.
Preparations
Take the following steps as preparation for following this tutorial:
- Start your project. This can be a pre-existing project, or a newly created project.
Introduction to TQL
TQL is an abbreviation for Tygron Query Language. It is a custom query language created to allow for obtaining statistical data from a Project. The language consists of "queries", which can be interpreted as questions asked of the Project. Such a query is composed of a statement, which embodies the requested information, and a number of clauses, which define/filter the data taken into consideration.
TQL queries are an important tool for automated analyses of Projects, both of the Current Situation as well as any Future Designs.
TQL queries by themselves can be used to obtain bits of information. In broader contexts, such as Excel Indicators or Panels, or scripts interacting via the API, the combination of multiple queries allows for obtaining large amounts of information which together can be used for more complex analyses.
Most statements return numerical values which can be used in calculations. Some statements return some form of text.
Query tool
To get started with the creation of queries, open the query tool:
The query tool is an assistive tool for the creation of queries. It helps by offering up options for which clauses can be added to statements and queries. It also allows for executing queries and seeing the results. This means that any created queries can be validated that they function as expected, but also that small bits of information can be requested on-the-fly.
When the query tool opens, a simple query is already composed.
If any clauses are listed, click on "Remove clause" for each of them until no clauses remain. Only the statement should remain.
Ensure the query type is set to "SELECT", which means to request data from the Project.
Ensure the statement is set to "LANDSIDE", which is a request for surface area.
Click on "Execute Query".
The result shown is the surface area found in the Project, unqualified. It will be the size of the Project in its entirety.
Next, click on "Add clause". This adds a qualifier to the query; a filter or rule the data must conform to before being taken into consideration.
Set the clause to "NEIGHBORHOOD", and select a Neighborhood which is well present in the Project.
Then, click on "Execute Query" again.
The result shown is the surface area which lies in the selected Neighborhood.
Note that the composed query is shown in the query tool as well. The dropdowns allow for (and guide) the selection of the individual parts of the query, but the full query is all components strung together.
Also note that using the dropdown, a Neighborhood could be selected by name, but in the actual query the ID of the Neighborhood is used. If the name of the Neighborhood (or any other Item being queried) is ever changed, the ID remains unchanged and thus the query will remain functional.
Basic queries
Statements
To create queries effectively, some knowledge of which statements are available is important. Construct the following queries and see the results:
- SELECT_NAME
- The name of a specific Item.
Create and execute the following query:
SELECT_NAME_WHERE_NEIGHBORHOOD_IS_...
The result is the name of the Neighborhood queried.
- SELECT_LANDSIZE
- The amount of surface area matching whichever qualifiers are provided in the clauses.
Create and execute the following query:
SELECT_LANDSIZE_WHERE_
The result is the size of the entire Project area.
- SELECT_LOTSIZE
- The amount of surface area which is taken up by Buildings such as apartments, roads, parks and trees. It's effectively the footprint of all constructions.
Create and execute the following query:
SELECT_LOTSIZE_WHERE_
The result is the surface area within the Project area which is taken up by Buildings.
- SELECT_FLOORSIZE
- The footprint of constructions, multiplied by their respective floors. The amount of space which the found constructions contain for use. This includes "single floor" constructions like roads and trees, unless further qualified.
Create and execute the following query:
SELECT_FLOORSIZE_WHERE_
The result is the total floorsize of all Buildings in the Project area.
- SELECT_UNITS
- The amount of housing units present. This is calculated by dividing the floorspace of Buildings by their respective UNIT_SIZE Attributes. Buildings which are not representative of housing are ignored.
Create and execute the following query:
SELECT_UNITS_WHERE_
The result is the total amount of housing units in the Project area. Note that this may include a fractional housing unit, as it is calculated based on the known/computable floor sizes.
Clauses
- WHERE_NEIGHBORHOOD_IS_...
- The data must be related to, or inside of, this Neighborhood.
Create and execute the following query:
SELECT_UNITS_WHERE_NEIGHBORHOOD_IS_...
The result is the total amount of housing units in the specified Neighborhood. Note that this may include a fractional housing unit, as it is calculated based on the known/computable floor sizes.
- WHERE_CATEGORY_IS_...
- The data requested is related to Buildings, and those Buildings must be of a specific Category.
Create and execute the following query:
SELECT_FLOORSIZE_WHERE_CATEGORY_IS_OFFICES
The result is the amount of office space in the Project area.
- WHERE_STAKEHOLDER_IS...
- The data must be related to, or owned by, this Stakeholder.
Create and execute the following query, with the Municipal Stakeholder selected for the STAKEHOLDER clause:
SELECT_LOTSIZE_WHERE_STAKEHOLDER_IS...
The result is the amount of built surface area which is owned by the Municipality.
- WHERE_FUNCTIONMULT_IS_...
- WHERE_CATEGORYMULT_IS_...
- WHERE_ATTRIBUTE_MULT_IS_...
- The data requested is related to Buildings, and the found amount is multiplied by the respective Function Values or Attributes.
Create and execute the following query:
SELECT_FLOORSIZE_WHERE_CATEGORYMULT_IS_PARKING_LOTS_DEMAND_PER_M2
The result is the amount of parking spots which are required to meet the parking demand of all Buildings in the Project area. This is calculated by obtaining all the floorsize of all Buildings, and then multiplying it by the respective parking demand for all Buildings.
Create and execute the following query:
SELECT_FLOORSIZE_WHERE_CATEGORYMULT_IS_PARKING_LOTS_PER_M2
The result is the amount of parking spots which are available in the Project area. This is calculated by obtaining all the floorsize of all Buildings, and then multiplying it by the respective parking supply for all Buildings.
Assignments
- Create a query to find the amount of social housing in the Project area which is owned by a collective corporation.
- Create a query to find the surface area in a Neighborhood which is taken up by shops and restaurants.
Grid queries
Queries can be used to consult grid data as well. Spatial calculations can produce produce results which allow for a general estimation of outcomes, but of which the exact values may be more difficult to read. For example, a Heat Stress Overlay may compute the location of hot or cool locations, but it may be difficult to compare optically how two different locations compare to one another.
To experiment with queries for grid calculation results, a Grid Overlay should be present in the Project. A Heat Stress Overlay is a good Overlay to experiment with.
Ensure a Heat Stress Overlay is present in the Project
If necessary, ensure the Heat Stress Overlay is recalculated as well.
Grid clauses
Construct the following queries and see the results.
- WHERE_GRID_IS_...
- The grid to use. Whenever a query is constructed to consult data related to a query, the consulted grid must be specified as well.
- WHERE_TIMEFRAME_IS_...
- The Timeframe of the grid to use. When absent, the last Timeframe of the Grid Overlay is used.
- WHERE_MINGRIDVALUE_IS_...
- Consulting only grid cells the value of which is at least the specified value. (Inclusive, so a cell with the exact value is included.)
- WHERE_MAXGRIDVALUE_IS_...
- Consulting only grid cells the value of which is at most the specified value. (Exclusive, so a cell with the exact value is excluded.)
Create and execute the following query, with the Heat Stress Overlay selected for the GRID clause:
SELECT_LANDSIZE_WHERE_MINGRIDVALUE_IS_35.0_AND_MAXGRIDVALUE_IS_45.0_AND_GRID_IS_...
The result is the surface area in the Project area which has calculated temperatures in the range of 35°C to 45°C.
Grid statements
Construct the following queries and see the results.
- SELECT_GRIDAVG_...
- The average value of grid values.
Create and execute the following query, with the Heat Stress Overlay selected for the GRID clause:
SELECT_GRIDAVG_WHERE_GRID_IS_...
The result is the average temperature in the Project area.
Assignments
- Create a query to obtain the average temperature in a specific neighborhood.
- Create a query to obtain the surface area of roads in a specific neighborhood with a temperature of at most 40 degrees.
Complex and combined queries
Final assignments
Final notes
Although not part of the general explanation provided in this tutorial, the following notes are important to keep in mind:
- The editor interface will generally present the first 3 inputs (A, B, and C) of the Combo Overlay. However, a total of 10 inputs can be added and used, by switching to the "inputs" tab.
Tutorial completed
Congratulations. You have now completed this tutorial. In it, you have learned how to create Combo Overlays, and how to use Average Overlays to rasterize data for use in the Combo Overlay.