How to do it...

The steps you need to follow to complete this recipe are as follows:

  1. As an initial test, you will export the first six months of the tmax for 2012 (the first six bands in the tmax_2012_multi PostGIS raster table) using the gdal_translate command:
      $ gdal_translate -b 1 -b 2 -b 3 -b 4 -b 5 -b 6      PG:"host=localhost port=5432 dbname='postgis_cookbook'      user='me' password='mypassword' schema='chp01'      table='tmax_2012_multi' mode='2'" tmax_2012_multi_123456.tif
  1. As the second test, you will export all of the bands, but only for the geographic area containing Italy. Use the ST_Extent command to get the geographic extent of that zone:
      postgis_cookbook=# SELECT ST_Extent(the_geom)       FROM chp01.countries WHERE name = 'Italy';

The output ...

Get PostGIS Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.