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

Creating spatial vectors with SQL

You now know how to upload your data, but what happens when things don’t go as expected?

Workflows that work best also introduce you to troubleshooting guidelines and where to focus if things don’t go as planned:

  1. Figure 4.1 shows the data when we select View/Edit Data while right-clicking on the table name in pgAdmin.

Where is the data?

Figure 4.1 – Data not imported into pgAdmin

Figure 4.1 – Data not imported into pgAdmin

  1. When we head over to QGIS to import the data (as a geojson file), we are greeted by this error message:
    Error 6
    Feature write errors:
    Creation error for features from #-9223372036854775808 to #-9223372036854775808. Provider errors was:
    PostGIS error while adding features: ERROR:  duplicate key value violates unique constraint "tiger2020LA_block_pkey"
    DETAIL:  Key (id)=(athens) already exists.
    Stopping after 100451 error(s)
    Only 0 of 100451 features written.

When exploring...