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
Section 1: Getting Started with Geospatial Analytics
Section 2: SQL for Spatial Analytics

Running queries in QGIS

How would you look at Los Angeles County by actual percentages of Hispanic and Latino populations by tract? We don’t have that information but we can add a column that will calculate the total for us.

Let’s go back to the Field calculator tool in QGIS. The Field calculator tool is great for computing a new vector layer (leaving the underlying data untouched). The dataset lists populations as totals, so a simple equation was able to generate a new column showing the populations as percentages based on the underlying total population of the tract, as in Figure 4.13.

Figure 4.13 – The Field calculator tool creating a new column in QGIS

Figure 4.13 – The Field calculator tool creating a new column in QGIS

When you scroll down to Fields and Values, you will be able to select the fields and add the calculation in the Expression window. The new field will show up as a data layer in the canvas, labeled Calculated.

Run the query and you will be able to view your input parameters...