[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] How to cast a 16BUI to a 32BF raster?
From:       Pierre Racine <Pierre.Racine () sbf ! ulaval ! ca>
Date:       2013-10-23 14:57:46
Message-ID: 87A96661E65C5541AB4D20721C2DD7F8CFCA3D7325 () EXCH-MBX-A ! ulaval ! ca
[Download RAW message or body]

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: postgis-users-bounces@lists.osgeo.org [mailto:postgis-users-
> bounces@lists.osgeo.org] On Behalf Of Guido LEMOINE
> Sent: Wednesday, October 23, 2013 10:30 AM
> To: postgis-users@lists.osgeo.org
> 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
postgis-users@lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic