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

Importing additional data – power plants

For example, if we want to look at the location of Power_Plants in Puerto Rico, we can upload the data and select the data from Puerto Rico, as seen in Figure 7.13:

Figure 7.13 – Public power plants in Puerto Rico

Figure 7.13 – Public power plants in Puerto Rico

Click on the layers icon at the top right-hand corner of the canvas and explore the options for basemaps that are available in pgAdmin:

SELECT * FROM public."Power_Plants"
WHERE statename = 'Puerto Rico'
ORDER BY id ASC

There are also times when the basemap should fade into the background to highlight another feature, such as when we look at the change in waterways after weather events, as shown in Figure 7.14 (2019) and Figure 7.15 (2022):

SELECT * FROM public.pr_multipolygons_2019
WHERE "natural" = 'water'
ORDER BY id ASC LIMIT 100000
…..
Figure 7.14 – A 2019 representation of a natural multipolygon, n=362

Figure 7.14 – A 2019 representation of a natural multipolygon...