diff --git a/doc/using_raster_dataman.xml b/doc/using_raster_dataman.xml index 9b946020c..c6e6db5f9 100644 --- a/doc/using_raster_dataman.xml +++ b/doc/using_raster_dataman.xml @@ -718,5 +718,29 @@ $$ LANGUAGE plpythonu;]]> C:/temp/slices5.png + + Outputting Rasters with PSQL + Sadly PSQL doesn't have easy to use built-in functionality for outputting binaries. This is a bit of a hack and based on one of the suggestions outlined in + Clever Trick Challenge -- Outputting bytea with psql that piggy backs on PostgreSQL somewhat legacy large object support. To use first launch your psql commandline connected to your database. + + Unlike the python approach, this approach creates the file on your local computer. + SELECT oid, lowrite(lo_open(oid, 131072), png) As num_bytes + FROM + ( VALUES (lo_create(0), + ST_AsPNG( (SELECT rast FROM aerials.boston WHERE rid=1) ) + ) ) As v(oid,png); +-- you'll get an output something like -- + oid | num_bytes +---------+----------- + 2630819 | 74860 + +-- next note the oid and do this replacing the c:/test.png to file path location +-- on your local computer + \lo_export 2630819 'C:/temp/aerial_samp.png' + +-- this deletes the file from large object storage on db +SELECT lo_unlink(2630819); + +