- Practical GIS
- Gábor Farkas
- 311字
- 2021-07-02 22:49:15
SQL in GIS
SQL is the query language of relational databases. Traditionally, it was developed to help make easy and powerful queries on relational tables. As attribute data can be considered tabular, its power for creating intuitive queries on vector layers is unquestionable. No matter if some modern GIS software uses an object-oriented structure for working with vector data internally, the tradition of using SQL, or near-SQL syntax for creating simple queries has survived. This language is very simple at its core, thus, it is easy to learn and understand. A simple query on a database looks like the following:
SELECT * FROM table WHERE column = value;
It uses the * wildcard for selecting everything from the table named table, where the content of the column named column matches value. In GIS software, like QGIS, this line can be translated to the following:
SELECT * FROM layer WHERE column = value;
Furthermore, as basic queries only allow selecting from one layer at a time, the query can be simplified as the software knows exactly which layer we would like to query. Therefore, this simple query can be formulated in a GIS as follows:
column = value
There is one final thing we have to keep in mind. Based on the software we use, these queries can be turned into real SQL queries used on internal relational tables, or parsed into something entirely different. As a result, GIS software can have their own SQL flavor with their corresponding syntactical conventions. In QGIS, the most important convention is how we differentiate column names from regular strings. Column names are enclosed in double quotation marks, while strings are enclosed in single ones. If we turn the previous query into a QGIS SQL syntax and consider value as a string, we get the following query:
"column" = 'value'
- Advanced Splunk
- 案例式C語言程序設(shè)計(jì)
- Learn to Create WordPress Themes by Building 5 Projects
- 實(shí)用防銹油配方與制備200例
- INSTANT MinGW Starter
- Python Geospatial Development(Second Edition)
- 游戲程序設(shè)計(jì)教程
- 琢石成器:Windows環(huán)境下32位匯編語言程序設(shè)計(jì)
- Microsoft Azure Storage Essentials
- Learning Apache Karaf
- Kubernetes源碼剖析
- JBoss:Developer's Guide
- Java并發(fā)編程之美
- C陷阱與缺陷
- RESTful Web API Design with Node.js