Database Reference
In-Depth Information
4. Refer to the previous two recipes for more information about the preceding
parameters.
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
(thefirstsixbandsinthe
tmax_2012_multi
PostGISrastertable)usingthe
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
2. Asthesecondtest,youwillexportallofthebands,butonlyforthegeograph-
ic area containing Italy. Use the
ST_Extent
command for getting the geo-
graphic extent of that zone:
postgis_cookbook=# SELECT
ST_Extent(the_geom) FROM chp01.countries
WHERE name = 'Italy';
The output of the preceding command is as follows:
st_extent
------------------------------------------------------------
BOX(6.61975999999999 36.649162,18.514999
47.0947189999999)
(1 row)
3. Nowusethe
gdal_translate
commandwiththe
-projwin
optionforob-
taining the desired purpose: