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

Importing data

The simplest way to import data, if you are on a Mac especially, is by using QGIS.

You should now have your database created in pgAdmin. Remember you will need to have PostgreSQL open to connect to the server before launching pgAdmin.

Now, open QGIS. The server port and the QGIS server port should both be 5432 (or whichever port you have assigned). Scroll to the Browser panel. If it isn’t already docked on your canvas, select View >> Panels and select Browser and Layer to add them to your workspace.

Figure 2.8 shows the Browser panel. On the left of the screenshot, you can scroll to your Home folder to see your folder hierarchy from your local computer. I download datasets to my downloads folder. Scroll to your downloads folder:

Figure 2.8 – QGIS canvas with panels and DB Manager

Figure 2.8 – QGIS canvas with panels and DB Manager

Right-click on the folder and open it to view a shape file or other geometry. Choose, and add "layer to project". Next, I...