Book Image

Geospatial Analysis with SQL

By : Bonny P McClain
Book Image

Geospatial Analysis with SQL

By: Bonny P McClain

Overview of this book

Geospatial analysis is industry agnostic and a powerful tool for answering location questions. Combined with the power of SQL, developers and analysts worldwide rely on database integration to solve real-world spatial problems. This book introduces skills to help you detect and quantify patterns in datasets through data exploration, visualization, data engineering, and the application of analysis and spatial techniques. You will begin by exploring the fundamentals of geospatial analysis where you’ll learn about the importance of geospatial analysis and how location information enhances data exploration. Walter Tobler’s second law of geography states, “the phenomenon external to a geographic area of interest affects what goes on inside.” This quote will be the framework of the geospatial questions we will explore. You’ll then observe the framework of geospatial analysis using SQL while learning to create spatial databases and SQL queries and functions. By the end of this book, you will have an expanded toolbox of analytic skills such as PostGIS and QGIS to explore data questions and analysis of spatial information.
Table of Contents (13 chapters)
Free Chapter
1
Section 1: Getting Started with Geospatial Analytics
6
Section 2: SQL for Spatial Analytics

SQL data queries using the graphical query builder

The query builder is SQL-like in its language syntax, and it is worth an introduction as part of an independent workflow. For example, simply because I code in Python or write SQL queries doesn’t mean I avoid a good shortcut here and there. Let’s take a look at the query builder and then explore how to integrate SQL syntax into our filters and code expressions.

First, we will access the query builder. Follow these steps:

  1. Select Layer from the menu in QGIS, scroll down to Layer Properties, and activate it by clicking on it, as shown in Figure 6.1:
Figure 6.1 – Layer properties in QGIS

Figure 6.1 – Layer properties in QGIS

  1. When you click on the Layer Properties option, the window opens, as shown in Figure 6.2. Select Source and the page will display the following options:
    • Settings: Displays the layer name and data source encoding. The default is UTF-8.
    • Assigned Coordinate Reference System (CRS): This operates...