Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#932 closed task (fixed)

[raster] ST_StdDev

Reported by: Bborie Park Owned by: Bborie Park
Priority: medium Milestone: PostGIS 2.0.0
Component: raster Version: master
Keywords: history Cc:

Description

A function to get the standard deviation (or sample deviation if approximating) of a raster's band.

  1. ST_StdDev(rast raster, nband int, ignore_nodata boolean) → double

returns the standard deviation

nband: index of band to process on

ignore_nodata: if TRUE, any pixel who's value is nodata is ignored.

ST_StdDev(rast, 2, TRUE)
  1. ST_StdDev(rast raster, nband int) → double

assumes ignore_nodata = TRUE

ST_StdDev(rast, 2)
  1. ST_StdDev(rast raster, ignore_nodata boolean) → double

assumes band index = 1

ST_StdDev(rast, FALSE)
  1. ST_StdDev(rast raster) → double

assumes band index = 1 and ignore_nodata = TRUE

ST_StdDev(rast)

Four approximation functions are also proposed sacrificing some accuracy for speed, especially on large rasters (10000 x 10000).

  1. ST_ApproxStdDev(rast raster, nband int, ignore_nodata boolean, sample_percent double precision) → double

sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider in computing the summary stats.

ST_ApproxStdDev(rast, 3, FALSE, 0.1)

ST_ApproxStdDev(rast, 1, TRUE, 0.5)
  1. ST_ApproxStdDev(rast raster, ignore_nodata boolean, sample_percent double precision) → double

assumes that nband = 1

ST_ApproxStdDev(rast, FALSE, 0.01)

ST_ApproxStdDev(rast, TRUE, 0.025)
  1. ST_ApproxStdDev(rast raster, sample_percent double precision) → double

assumes that nband = 1 and ignore_nodata = TRUE

ST_ApproxStdDev(rast, 0.25)
  1. ST_ApproxStdDev(rast raster) → double

assumes that nband = 1, ignore_nodata = TRUE and sample_percent = 0.1

ST_ApproxStdDev(rast)

Attachments (1)

st_stddev.patch (8.0 KB ) - added by Bborie Park 13 years ago.
Adds ST_StdDev function. ST_SummaryStats is required for this patch.

Download all attachments as: .zip

Change History (5)

comment:1 by Bborie Park, 13 years ago

Status: newassigned

A set of ST_StdDev and ST_ApproxStdDev variations for processing coverages:

  1. ST_StdDev(rastertable text, rastercolumn text, nband int, hasnodata boolean) → double precision
ST_StdDev('tmax_2010', 'rast', 1, FALSE)

ST_StdDev('precip_2011', 'rast', 1, TRUE)
  1. ST_StdDev(rastertable text, rastercolumn text, nband int) → double precision

hasnodata is set to FALSE

ST_StdDev('tmax_2010', 'rast', 1)
  1. ST_StdDev(rastertable text, rastercolumn text, hasnodata boolean) → double precision

nband is set to 1

ST_StdDev('precip_2011', 'rast', TRUE)
  1. ST_StdDev(rastertable text, rastercolumn text) → double precision

nband is set to 1 and hasnodata is set to FALSE

ST_StdDev('tmin_2009', 'rast')

Variations for ST_ApproxStdDev are:

  1. ST_ApproxStdDev(rastertable text, rastercolumn text, nband int, hasnodata boolean, sample_percent double precision) → double precision
ST_ApproxStdDev('tmax_2010', 'rast', 1, FALSE, 0.5)

ST_ApproxStdDev('precip_2011', 'rast', 1, TRUE, 0.2)
  1. ST_ApproxStdDev(rastertable text, rastercolumn text, nband int, sample_percent double precision) → double precision

hasnodata is set to FALSE

ST_ApproxStdDev('tmax_2010', 'rast', 1, 0.5)

ST_ApproxStdDev('precip_2011', 'rast', 1, 0.2)
  1. ST_ApproxStdDev(rastertable text, rastercolumn text, hasnodata boolean, sample_percent double precision) → double precision

nband is set to 1

ST_ApproxStdDev('tmax_2010', 'rast', FALSE, 0.5)

ST_ApproxStdDev('precip_2011', 'rast', TRUE, 0.2)
  1. ST_ApproxStdDev(rastertable text, rastercolumn text, sample_percent double precision) → double precision

nband is set to 1 and hasnodata is set to FALSE

ST_ApproxStdDev('tmax_2010', 'rast', 0.5)

ST_ApproxStdDev('precip_2011', 'rast', 0.2)
  1. ST_ApproxStdDev(rastertable text, rastercolumn text) → double precision

nband is set to 1, hasnodata is set to FALSE and sample_percent is set to 0.1

ST_ApproxStdDev('tmax_2010', 'rast')

ST_ApproxStdDev('precip_2011', 'rast')

The standard deviation returned is the cumulative standard deviation of all raster tiles.

by Bborie Park, 13 years ago

Attachment: st_stddev.patch added

Adds ST_StdDev function. ST_SummaryStats is required for this patch.

comment:2 by Bborie Park, 13 years ago

Adds ST_StdDev function, which builds upon ST_SummaryStats. Merges cleanly against r7145.

The following patches must be merged first for this patch to merge cleanly:

  1. ST_Band
  1. ST_SummaryStats
  1. ST_Mean

comment:3 by Bborie Park, 13 years ago

Keywords: history added
Resolution: fixed
Status: assignedclosed

Added in r7150

comment:4 by Bborie Park, 13 years ago

Milestone: PostGIS Raster FuturePostGIS 2.0.0
Note: See TracTickets for help on using tickets.