This chapter covers:
- Geometry, geography, and raster spatial types and subtypes
- Geometry and geography type modifiers
- Spatial catalog tables
- How to create spatial columns and populate them
In the first chapter we teased you with the potential that you can unlock with PostGIS. This chapter will start to show you how, by delving deeper into the core spatial data types bundled with PostGIS. We’ll discuss each spatial type in detail. Once you’ve completed this chapter, you should know how to create table columns of these various types and how to populate them with spatial data.
Do keep in the back of your mind that PostgreSQL has its own built-in geometric types. These are
path. PostgreSQL geometry types have almost no functional support, are not adopted for GIS work, and are incompatible with the PostGIS geometry type. These geometry types have existed since the dawn of PostgreSQL and don’t follow the SQL/MM standards, nor do they support spatial coordinate systems. We advice staying away from them for GIS.
If you’ve already started using them, PostGIS rescues you with functions and casts to convert the PostgreSQL types to PostGIS
geometry. For example, the following code converts a PostgreSQL
circle to an equivalent PostGIS
geometry. PostGIS doesn’t have conversion for all PostgreSQL geometry types. As a work around we cast box and circle to PostgreSQL polygons before casting to PostGIS geometry.