In this chapter, we will look at how you can use a PostGIS database to store and work with spatial data. In particular, we will cover:
The concept of a spatially enabled database
Spatial indexes and how they work
How PostGIS acts as an extension to the PostgreSQL relational database
How to install PostgreSQL, PostGIS, and the
psycopg2
Python database adapter onto your computerHow to set up and configure a spatial database using PostGIS
How to use the
psycopg2
database adapter to access a spatial database from your Python codeHow to create, import, and query against spatial data using Python
Recommended best practices for storing spatial data in a database
This chapter is intended to be an introduction to using databases in a geospatial application. Chapter 8, Working with Spatial Data, will build on this to perform powerful spatial queries not possible using shapefiles and other geospatial data files.