[postgis-users] How to cast a 16BUI to a 32BF raster?

Guido LEMOINE guido.lemoine at jrc.ec.europa.eu
Wed Oct 23 07:29:57 PDT 2013


Dear List,

 

First of all, I wish to congratulate the postgis developers with the (new to
me) raster functionality. It's a real game changer.

 

I am experimenting with (free!) Landsat-8 data, generating indices through
queries. Landsat-8 bands come as 16BUI type data.

In order to avoid integer division issues, I cast to 32BF as follows:

 

select st_reclass(rast, '0-65535:0-65535', '32BF') from l8tiled where rid =
5644  -- l8tiles holds the tiled single-band rasters, rid is an arbitrary
tile ID

 

OR

 

select st_mapalgebra(rast, '32BF', '[rast]') from l8tiled where rid = 5644  

 

Both work, with the first being the fastest (because implement directly in
C). 11 and 21 ms for a 64 by 64 pixel tile, respectively (on Linux 64
bit/Dell T7400 PostgreSQL 9.3/Postgis 2.1).

The first is not very elegant, though, as it requires the somewhat awkward
reclassexpr. 

 

Is there a neater way to do this? If I use '' (empty string) for the
reclassexpr, the cast does not work (i.e. the result remains 16BUI).

Guido Lemoine

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20131023/1bde3db8/attachment.html>


More information about the postgis-users mailing list