[postgis-devel] [PostGIS] #903: [raster] ST_Reclass
PostGIS
trac at osgeo.org
Thu Apr 7 17:25:16 PDT 2011
#903: [raster] ST_Reclass
----------------------------+-----------------------------------------------
Reporter: dustymugs | Owner: dustymugs
Type: task | Status: new
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis raster | Version: 1.5.X
Keywords: |
----------------------------+-----------------------------------------------
Due to limitations in the JPEG (8BUI) and PNG (8BUI and 16BUI) raster
formats regarding supported pixel/data types, a method must be provided
that can convert a band of a larger data type to 8BUI, amongst other uses.
As proposed by Pierre...
ST_Reclass(rast raster, nband int, reclassexpr text, pixeltype text,
[nband int, reclassexpr text, pixeltype text]...)
The above allows the function to reclass one or more bands at the same
time.
The reclassexpr argument is a string like
'rangefrom:rangeto, [rangefrom:rangeto]'
where the ranges are 'int-int' or just 'int' (float or double if
appropriate).
So, you could reclass one band to three new R, G and B bands:
red: min(covmin, 0)-0:0,0-max(covmax, 0):0-255
green: min(covmin, 0)-0:200,0-max(covmax, 0):0-255
blue: min(covmin, 0)-0:255,0-max(covmax, 0)/2:0, max(covmax,
0)/2-max(covmax, 0):0-255
{{{
CREATE TABLE elevationcov AS
SELECT ST_Reclass(rast,
1, LEAST(covmin, 0)::text || '-0:0,0-' ||
GREATEST(covmax, 0)::text || ':0-255', '8BUI',
1, LEAST(covmin, 0)::text || '-0:200,0-' ||
GREATEST(covmax, 0)::text' || ':0-255','8BUI',
1, LEAST(covmin, 0)::text || '-0:255,0-' ||
(GREATEST(covmax, 0)/2)::text' || ':0,' || (GREATEST(covmax, 0)/2)::text'
|| ':' || GREATEST(covmax, 0)::text || ':0-255', '8BUI')
FROM mycoverage
}}}
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/903>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-devel
mailing list