Database Reference
In-Depth Information
Importing
raster
data
with
the
raster2pgsql PostGIS command
PostGIS2.0nowhasfullsupportforrasterdatasets,anditispossibletoimportraster
datasets using the
raster2pgsql
command.
Inthisrecipe,youwillimportarasterfiletoPostGISusingthe
raster2pgsql
com-
mand.Thiscommand,includedinanyPostGISdistributionfromVersion2.0onward,
isabletogenerateansqldumptobeloadedinPostGISforanyGDALraster-suppor-
ted format (in the same fashion that the command
shp2pgsql
does for shapefiles).
AfterloadingtherastertoPostGIS,youwillinspectitbothwithSQLcommands(ana-
lyzingtherastermetadatainformationcontainedinthedatabase),andwiththe
gdal-
info
command-lineutility(tounderstandthewaytheinput
raster2pgsql
paramet-
ers have been reflected in the PostGIS import process).
YouwillfinallyopentherasterinaDesktopGISandtryabasicspatialquery-mixing
vector and raster tables.
Getting ready
Weneedthefollowinginplacebeforewecanproceedwiththestepsrequiredforthe
recipe:
1. From the
worldclim.org
website, download the current raster data (
ht-
tp://www.worldclim.org/current
)
forminandmaxtemperatures(onlytheraster
for max temperatures will be used for this recipe). Alternatively, use the
onesprovidedinthebookdatasets(
data/chp01
).Eachofthetwoarchives
(
data/tmax_10m_bil.zip
and
data/tmin_10m_bil.zip
) contain 12
rastersintheBILformat,oneforeachmonth.Youcanlookformoreinforma-
tion at
http://www.worldclim.org/formats
.
2. Extractthetwoarchivestoadirectorynamed
worldclim
inyourworkingdir-
ectory.
3. Renameeachrasterdatasettoanameformathavingtwodigitsforthemonth,
for example,
tmax1.bil
and
tmax1.hdr
will become
tmax01.bil
and
tmax01.hdr
.