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)

Outputting rasters using GDAL


We have seen ogr2ogr in action already, and now it is time to give two GDAL tools a spin: gdal_translate and gdalwarp. The former is a translation utility that can change the format of a raster datasource while the latter is a reprojection utility. Therefore, in order to extract a reprojected raster from a PostGIS database, we need to perform two steps:

  1. Extract the raster using gdal_translate
  2. Perform a reprojection using gdalwarp

In order to get some help with both utilities, simply type the following in the console:

gdal_translate

You could also use the following:

gdalwarp

The most important parameters of gdal_translate for our scenario are:

  • -of: Specifies the output format (use gdal_translate -formats to obtain information on the supported formats).
  • -outsize xsize[%] ysize[%]: Specifies the output raster size. It can be expressed in pixels or a percentage. If it is not used 100%, then the original size is assumed
  • PG (PgSQL connection opts): PgSQL connection options...