90 | | '''Important:''' The out-db raster support for PostGIS Raster is still under development. Please, don't use this option. |
91 | | |
92 | | '''Example 1''': |
93 | | |
94 | | Load [http://dl.dropbox.com/u/6599273/utm.tif this one-band grayscale image] (utm.tif) on PostGIS using loader script: |
95 | | |
96 | | {{{ |
97 | | >$ python raster2pgsql.py -r /path/to/utm.tif -t [schema.]utm -l 1 -k 64x64 -o utm.sql -s 26711 -I -M |
98 | | }}} |
99 | | |
100 | | In this example, the script generates a SQL output (redirected to the file ''utm.sql''). This SQL code, when executed in PostgreSQL create a new table with the image ''utm.tif''. It will be tiled as regular blocking arrangement with blocks of 64x64px. Each image block will be a row of the raster table. To execute the code in PostgreSQL, you must run this command from the console: |
101 | | |
102 | | {{{ |
103 | | >$ psql -d <raster_database> -f utm.sql -U <user> -W |
104 | | }}} |
105 | | |
106 | | ''raster_database'' must be a PostgreSQL database with the PostGIS Raster extension enabled. ''user'' must have privileges to create tables and insert values in the database. |
107 | | |
108 | | '''Example 2''': |
109 | | |
110 | | Load [http://dl.dropbox.com/u/6599273/katrina.tif this RGB image] (katrina.tif) in PostGIS using the loader script: |
111 | | |
112 | | {{{ |
113 | | >$ python raster2pgsql.py -r /path/to/katrina.tif -t katrina -l 1 -k 64x64 -o katrina.sql -s 4326 -I -M |
114 | | }}} |
115 | | |
116 | | As in ''Example 1'', this code generates a SQL file, called ''katrina.sql'' with the SQL code to add the image ''katrina.tif'' to PostGIS using a regular blocking arrangement with blocks of 64x64px. Again, a new raster table will created and each image block will be stored in one row of the raster table. To execute the code, type: |
117 | | |
118 | | {{{ |
119 | | >$ psql -d <raster_database> -f katrina.sql -U <user> -W |
120 | | }}} |
121 | | |
122 | | |
123 | | '''Example 3''': |
124 | | |
125 | | Using the second image (katrina.tif), you can load a lower resolution overview of the image (containing only a quarter of the pixels) in PostGIS. |
126 | | |
127 | | {{{ |
128 | | >$ python raster2pgsql.py -r /path/to/katrina.tif -t katrina -l 2 -V -k 64x64 -o katrina_ov2.sql -s 4326 -I -M |
129 | | }}} |
130 | | |
131 | | The key options are: |
132 | | * The '''-V''' flag. This flag makes the loader to create a new table to store the overviews' metadata. If you want to load several images with overviews, you'll have to use this flag '''only the first time''' the loader script is called, to create the overviews' metadata table only once. |
133 | | * The '''-l 2''' flag. This flag forces the loader script to create a table with a GDAL-provided overview of the original file, with an overview factor of 2. This is, half size. |
134 | | |
135 | | As usual, to execute the generated SQL code, run this command: |
136 | | |
137 | | {{{ |
138 | | >$ psql -d <raster_database> -f katrina_ov2.sql -U <user> -W |
139 | | }}} |
140 | | |
| 89 | The write support to GDAL PostGIS Raster driver is under development. |