mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-24 09:02:37 +00:00
Example of how to use only psql to output a raster image.
git-svn-id: http://svn.osgeo.org/postgis/trunk@9192 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
2936722b2a
commit
148bed9a94
|
@ -718,5 +718,29 @@ $$ LANGUAGE plpythonu;]]></programlisting>
|
|||
C:/temp/slices5.png
|
||||
</programlisting>
|
||||
</sect2>
|
||||
<sect2 id="RasterOutput_PSQL">
|
||||
<title>Outputting Rasters with PSQL</title>
|
||||
<para>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
|
||||
<ulink url="http://people.planetpostgresql.org/andrew/index.php?/archives/196-Clever-trick-challenge.html">Clever Trick Challenge -- Outputting bytea with psql</ulink> that piggy backs on PostgreSQL somewhat legacy large object support. To use first launch your psql commandline connected to your database.
|
||||
</para>
|
||||
<para>Unlike the python approach, this approach creates the file on your local computer.</para>
|
||||
<screen>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);
|
||||
</screen>
|
||||
</sect2>
|
||||
</sect1>
|
||||
</chapter>
|
||||
|
|
Loading…
Reference in a new issue