ST_AsBinary/ST_AsWKB — Return the Well-Known Binary (WKB) representation of the raster.


bytea ST_AsBinary ( raster rast , boolean outasin=FALSE ) ;

bytea ST_AsWKB ( raster rast , boolean outasin=FALSE ) ;


Returns the Binary representation of the raster. If outasin is TRUE, out-db bands are treated as in-db. Refer to raster/doc/RFC2-WellKnownBinaryFormat located in the PostGIS source folder for details of the representation.

This is useful in binary cursors to pull data out of the database without converting it to a string representation.


By default, WKB output contains the external file path for out-db bands. If the client does not have access to the raster file underlying an out-db band, set outasin to TRUE.

Enhanced: 2.1.0 Addition of outasin

Enhanced: 2.5.0 Addition of ST_AsWKB


SELECT ST_AsBinary(rast) As rastbin FROM dummy_rast WHERE rid=1;