Book Image

PostGIS Essentials

By : Angel Marquez
Book Image

PostGIS Essentials

By: Angel Marquez

Overview of this book

<p>PostGIS is one of the world's leading spatial databases, created as a geographic extension for PostgreSQL. With it, users are able to manipulate and visualize spatial data incredibly effectively and efficiently.</p> <p>PostGIS Essentials introduces you to the fundamentals of PostGIS, giving you easy access to one of the most popular and powerful spatial databases available today. You will begin by learning how to install and successfully set up PostGIS before covering how to create your first spatial database. The book will then help you to develop your skills further as you will learn how to insert GIS objects as well as how to select and filter GIS queries with clear and practical information. You will then learn how to display GIS data graphically and create effective visualizations. The book concludes with tips, tricks, and techniques to help you optimize PostGIS and improve the performance of your database.</p>
Table of Contents (16 chapters)
PostGIS Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Nonspatial queries


In the previous section, we have seen how our existing table can be modified in order to add more fields to it, which can make our data even more valuable. Well, we are now ready to develop our first query. We will get the basic information about it first using the standard function of PostgreSQL, then we will be adding complexities to our queries. It's very important to fully understand and dominate the grouping and filtering of SQL before we can apply the spatial functions. For this reason, we must refresh all these skills first. We will see a set of practical exercises that will help us to get basic information about the data stored in our data tables. The data tables in our databases aren't related to each other, so you can work with each one separately.

We will work with the tbl_buildings table first. Let's check how many registers from London we have stored in our table; to do this, we will run the following query:

SELECT COUNT(*) FROM tbl_buildings WHERE town='London...