If you are willing to do it you could write a ST_ChangePixelType(raster, 
newpixeltype) sql function that would automatically define the reclassexpr 
parameter to ST_Reclass...

We could then add it to the API.

Pierre

> -----Original Message-----
> From: [email protected] [mailto:postgis-users-
> [email protected]] On Behalf Of Guido LEMOINE
> Sent: Wednesday, October 23, 2013 10:30 AM
> To: [email protected]
> Subject: [postgis-users] How to cast a 16BUI to a 32BF raster?
> 
> 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

_______________________________________________
postgis-users mailing list
[email protected]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

Reply via email to