Changes between Version 61 and Version 62 of WKTRaster/SpecificationWorking03

Show
Ignore:
Timestamp:
04/15/11 08:16:25 (2 years ago)
Author:
dustymugs
Comment:

addition of ST_Reclass

Legend:

Unmodified
Added
Removed
Modified
  • WKTRaster/SpecificationWorking03

    v61 v62  
    407407---- 
    408408 
     409'''ST_Reclass(rast raster, VARIADIC argset reclassarg[]) -> raster''' 
     410 
     411Due 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.  ST_Reclass allows raster's band pixel values to be remapped from one range of numbers to another as well as between pixel types, e.g. 32BF to 8BUI. 
     412 
     413ST_Reclass returns a duplicate of the submitted raster with the bands specified to be reclassed being processed.  This means that if a raster with 5 bands are submitted and band 1 is to be reclassed, the output raster will have 5 bands with band 1 reclassified.  The other four bands will not be touched. 
     414 
     4151. ST_Reclass(rast raster, VARIADIC argset reclassarg[]) -> raster 
     416 
     417  rast: the raster whose specified bands are to be reclassified 
     418 
     419  reclassarg: a new custom type defining the parameters required for reclassifying a band's pixel values. 
     420 
     421{{{ 
     422CREATE TYPE reclassarg AS ( 
     423 
     424  nband int, 
     425 
     426  reclassexpr text, 
     427 
     428  pixeltype text, 
     429 
     430  nodata double 
     431 
     432);  
     433}}} 
     434 
     435    nband: index of the band to reclass (1-based) 
     436 
     437    reclassexpr: reclassification expression indicating the ranges to convert from and to.  More than one expression can be provided by separating the expression with a comma (,).  The values provided can be of any valid numeric type. 
     438 
     439      ''rangefrom:rangeto[, rangefrom:rangeto]'' 
     440 
     441{{{ 
     4420-100:0-10 
     443 
     4440-100:0-10, 101-1000:11-100 
     445 
     4460-100:0-10, 101-1000:11-100, 1001-10000:101-1000 
     447}}} 
     448 
     449      In the last example above, the default evaluation of the ranges is 
     450 
     451{{{ 
     452        0 <= x < 100 reclassified to 0 <= y <= 10 
     453 
     454        101 <= x < 1000 reclassified to 11 <= y <= 100 
     455 
     456        1001 <= x < 10000 reclassified to 101 <= y <= 1000 
     457}}} 
     458 
     459      To change the evaluation of rangefrom, use square brackets and parentheses. 
     460 
     461{{{ 
     4621. [a-b] = a <= x <= b 
     463 
     4642. (a-b] = a < x <= b 
     465 
     4663. [a-b) = a <= x < b 
     467 
     4684. (a-b) = a < x < b 
     469}}} 
     470 
     471      !#3 above is the default evaluation of x in the range a-b. The use of square brackets and parentheses are optional, so the examples below would be permitted. Missing notations substitute the appropriate notation from #3 above.  
     472 
     473{{{ 
     474[a-b = a <= x < b 
     475 
     476(a-b = a < x < b 
     477 
     478a-b] = a <= x <= b 
     479 
     480a-b) = a <= x < b 
     481}}} 
     482 
     483    pixeltype: the reclassified band's pixel type, e.g. 8BUI, 16BUI, 32BF 
     484 
     485    nodata: the nodata value of the reclassified band.  If the source band has a nodata value, all source pixel value equal to the source nodata value will be converted to the reclassified band's nodata value.  If set to NULL, the reclassified band will NOT have a nodata value specified. 
     486 
     487{{{ 
     488ST_Reclass(rast, ROW(1, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', NULL)); 
     489 
     490ST_Reclass(rast, ROW(1, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', 1001)); 
     491 
     492ST_Reclass(rast, 
     493  ROW(1, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', 1001), 
     494  ROW(2, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', 1001), 
     495  ROW(3, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', 1001), 
     496  ROW(5, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', 1001) 
     497) 
     498}}} 
     499 
     500  An expanded example 
     501 
     502{{{ 
     503SELECT ST_Reclass( 
     504  ST_Band(rast, ARRAY[1,1,1]),  
     505  1, LEAST(covmin, 0)::text || '-0:0,0-' || GREATEST(covmax, 0)::text || ':0-255', '8BUI', 
     506  2, LEAST(covmin, 0)::text || '-0:200,0-' || GREATEST(covmax, 0)::text' || ':0-255','8BUI', 
     507  3, 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') 
     508FROM mycoverage 
     509}}} 
     510 
     5112. ST_Reclass(rast raster, nband int, reclassexpr text, pixeltype text, nodata double) -> raster 
     512 
     513  provides a method to process just one band of a raster 
     514 
     515{{{ 
     516ST_Reclass(rast, 1, '0-100:0-10', '8BUI', 11) 
     517}}} 
     518 
     5193. ST_Reclass(rast raster, nband int, reclassexpr text, pixeltype text) -> raster 
     520 
     521  nodata parameter removed so reclassified band will NOT have a nodata value set 
     522 
     523{{{ 
     524ST_Reclass(rast, 1, '0-100:0-10', '8BUI') 
     525}}} 
     526 
     5274. ST_Reclass(rast raster, reclassexpr text, pixeltype text) -> raster 
     528 
     529  nband parameter removed so reclassified band is assumed to be 1.  nodata parameter removed so reclassified band has NO nodata value. 
     530 
     531{{{ 
     532ST_Reclass(rast, '0-100:0-10', '8BUI') 
     533}}} 
     534 
     5355. ST_Reclass(rast raster, reclassexpr text, pixeltype text, nodata double) -> raster 
     536 
     537  nband parameter removed so reclassified band is assumed to be 1 
     538 
     539{{{ 
     540ST_Reclass(rast, '0-100:0-10', '8BUI', 11) 
     541}}} 
     542 
     543---- 
     544 
    409545== '''Objective FV.02 - Being able to intersect vector and raster to produce raster.''' == 
    410546  
     
    607743'''ST_SelectByValue(raster|geometry, ‘expression’) -> same type as first argument'''[[BR]] 
    608744'''ST_Reclass(raster|geometry,string) -> same type as first argument'''[[BR]] 
     745 
     746Bborie: Implementation has been moved to FV.01 above. 
    609747 
    610748'''ST_MapAlgebra(raster|geometry, [raster|geometry,…] ‘mathematical expression’, ‘raster’ |’geometry’) -> raster/geometry'''