Book Image

Mastering PostGIS

By : Dominik Mikiewicz, Michal Mackiewicz , Tomasz Nycz
Book Image

Mastering PostGIS

By: Dominik Mikiewicz, Michal Mackiewicz , Tomasz Nycz

Overview of this book

PostGIS is open source extension onf PostgreSQL object-relational database system that allows GIS objects to be stored and allows querying for information and location services. The aim of this book is to help you master the functionalities offered by PostGIS- from data creation, analysis and output, to ETL and live edits. The book begins with an overview of the key concepts related to spatial database systems and how it applies to Spatial RMDS. You will learn to load different formats into your Postgres instance, investigate the spatial nature of your raster data, and finally export it using built-in functionalities or 3th party tools for backup or representational purposes. Through the course of this book, you will be presented with many examples on how to interact with the database using JavaScript and Node.js. Sample web-based applications interacting with backend PostGIS will also be presented throughout the book, so you can get comfortable with the modern ways of consuming and modifying your spatial data.
Table of Contents (9 chapters)

Creating an empty topology


After installing the topology extension, one more preparation step is needed before we can work with data: a new, empty topology has to be created. There are two functions for this: topology.ST_InitTopoGeo and topology.CreateTopology. The former is defined by the ISO standard, and accepts only one argument: the topology name. The latter is a non-standard version that allows the definition of additional parameters: the snapping tolerance, SRID, and dimensionality. Let's use the non-standard version:

SELECT topology.CreateTopology('my_topology', 4326, 0.00028, FALSE); 

The first argument defines the topology name, the second is SRID (in this case, WGS84), the third specifies the precision (in this case, 1 arc-second, which is about 30 meters at the equator), and the fourth determines whether the topology should store Z-coordinates.

As a result, the function should return the integer ID of the newly created topology. Let's have a look at the database structure now:

Newly...