Database Reference
In-Depth Information
Importing multiple rasters at a time
This recipe will guide you through the import of multiple rasters at a time.
Youwillfirstimportsomedifferentsinglebandrasterstoauniquesinglebandraster
table using the raster2pgsql command.
Then, you will try an alternative approach, merging the original single band rasters
in a virtual raster, having one band for each of the original rasters, and then load
themultibandrastertoarastertable.Foraccomplishingthis,youwillusetheGDAL
gdalbuildvrt commandand then load the data to PostGIS with raster2pgsql .
Getting ready
Besuretohavealltheoriginalrasterdatasetsyouhavebeenusingfortheprevious
recipe.
How to do it...
The steps you need to follow to complete this recipe are as follows:
1. ImportallthemaximumaveragetemperaturerastersinasinglePostGISras-
tertableusing raster2pgsql andthen psql (eventually,pipethetwocom-
mands if you are in Linux):
$ raster2pgsql -d -I -C -M -F -t 100x100
-s 4326 worldclim/tmax*.bil
chp01.tmax_2012 > tmax_2012.sql
$ psql -d postgis_cookbook -U me -f
tmax_2012.sql
2. CheckhowthetablewascreatedinPostGIS,queryingthe raster_columns
table. Here we are querying only some significant fields:
postgis_cookbook=# SELECT r_raster_column,
srid, ROUND(scale_x::numeric, 2) AS
scale_x, ROUND(scale_y::numeric, 2) AS
Search WWH ::




Custom Search