PostGIS Raster : Extending PostgreSQL for The Support of ... - CoDE
PostGIS Raster : Extending PostgreSQL for The Support of ... - CoDE
PostGIS Raster : Extending PostgreSQL for The Support of ... - CoDE
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 5<br />
User Guide<br />
Sometimes storing data using raster is the only choice such as imagery is only available in raster<br />
<strong>for</strong>mat. Moreover, users can get many other advantages resulting from the nature <strong>of</strong> raster data,<br />
which is a matrix <strong>of</strong> cell values. For example, this simple data structure <strong>of</strong>fers the ability to represent<br />
continuous surfaces as a grid <strong>of</strong> cell values and so enables easy spatial and statistical surface analysis.<br />
<strong>The</strong> ability to uni<strong>for</strong>m storage as points, lines and polygons, which are all vector features, could also<br />
be stored using raster data.<br />
<strong>The</strong> following section introduces instructions about how to execute some basic operations such as<br />
importing, exporting raster data, conversion and intersection between raster and vector data, along<br />
with other abilities that <strong>PostGIS</strong> <strong>Raster</strong> could <strong>of</strong>fer to users.<br />
5.1 Store and Manage <strong>Raster</strong>s<br />
5.1.1 Import <strong>Raster</strong>s<br />
User can import rasters from existing raster images stored in file system using raster2pgsql<br />
Python loader:<br />
(1) raster2pgsql.py -r "c:/temp/mytiffolder/*.tif" -t mytable -s 4326 -o table_name.sql<br />
(2) psql -d postgisdb -f table_name.sql -U -W<br />
<strong>The</strong> first command (1) generates a sql file that loads file_name.tif with SRID 4326 into a<br />
new table called mytable. <strong>The</strong> second command (2) runs the SQL script <strong>for</strong> loading the data into<br />
postgisdb.<br />
Or users can create their own rasters from SQL command:<br />
CREATE TABLE dummy_rast(rid integer, rast raster);<br />
INSERT INTO dummy_rast(rid, rast)<br />
VALUES<br />
-- <strong>Raster</strong>: 5 x 5 pixels, 3 bands, PT_8BUI pixel type, NODATA = 0<br />
(1,(’01000003009A9999999999A93F9A9999999999A9BF000000E02B274A4<br />
1000000007719564100000000000000000000000000000000FFFFF<br />
FFF050005000400FDFEFDFEFEFDFEFEFDF9FAFEFEFCF9FBFDFEFEF<br />
DFCFAFEFEFE04004E627AADD16076B4F9FE6370A9F5FE59637AB0E<br />
54F58617087040046566487A1506CA2E3FA5A6CAFFBFE4D566DA4C<br />
B3E454C5665’)::raster);<br />
5.1.2 Get and Set <strong>The</strong> <strong>Raster</strong> Properties<br />
• Upper left corner coordinates and trans<strong>for</strong>mation parameters<br />
–Get the upper left corner coordinates <strong>of</strong> all rasters in the table:<br />
62