#902 closed task (fixed)
[raster] ST_MinMax
Reported by: | Bborie Park | Owned by: | Bborie Park |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.0.0 |
Component: | raster | Version: | master |
Keywords: | history | Cc: |
Description
As part of the process to provide complete implementations of ST_AsJPEG and ST_AsPNG, a method is required to reclassify larger numbers unable to be contained in 8BUI (JPEG and PNG) and 16BUI (PNG). For this reclassification function, we need to get the min and max values of a band, thus ST_MinMax.
ST_MinMax(rast raster, nband int) -> set of record
returns one record of two columns (min, max)
ST_MinMax(rast, 2)
ST_MinMax(rast raster) -> set of record
assumes that the band index = 1
ST_MinMax(rast)
Attachments (5)
Change History (17)
comment:1 by , 14 years ago
Status: | new → assigned |
---|
comment:2 by , 14 years ago
comment:4 by , 14 years ago
Due to time it takes for ST_MinMax to run on large rasters, I would like to add a function that randomly samples a percentage of the pixels of a specified band for an approximate min and max. So, something like:
- ST_ApproxMinMax(rast raster, nband int, sample int)
sample: a value of between 0 and 100 indicating the percentage of the raster to sample
comment:5 by , 14 years ago
Attached patch for adding ST_MinMax and ST_ApproxMinMax support. Patch can be applied with the following in the base postgis source directory.
patch -p1 < st_minmax.patch
comment:6 by , 14 years ago
Forgot to mention that this is an incremental patch. The patch for ST_Band should be used first.
by , 14 years ago
Attachment: | st_minmax.2.patch added |
---|
New patch due to refactoring in preparation for computing additonal stats
comment:7 by , 14 years ago
Added patch (the patch for ST_Band must be applied first) that refactors the function in rt_api.c in preparation for calculation of additional stats. As it stands, the rt_api.c function currently computes...
- Mean
- Standard Deviation
- # of values used in the stats
The rt_api.c function will also return the actual values used in the stats for subsequent processing, e.g. ST_Histogram and ST_Quantile.
by , 14 years ago
Attachment: | st_minmax.3.patch added |
---|
Changes to ST_MinMax regarding the "sample" function parameter
comment:8 by , 14 years ago
New patch renames the ST_MinMax parameter "sample" to "sample_percent". It also changes the format of "sample_percent" from a number between 0 and 100 to 0 and 1, which is inline with the percentage format used for ST_ConvexHull.
by , 14 years ago
Attachment: | st_minmax.4.patch added |
---|
Function parameter "no_nodata" is now "hasnodata" and behaves like the identical parameter of ST_Intersects
comment:9 by , 13 years ago
A set of ST_MinMax and ST_ApproxMinMax variations for processing coverages:
- ST_MinMax(rastertable text, rastercolumn text, nband int, hasnodata boolean) -> record
ST_MinMax('tmax_2010', 'rast', 1, FALSE) ST_MinMax('precip_2011', 'rast', 1, TRUE)
- ST_MinMax(rastertable text, rastercolumn text, nband int) -> record
hasnodata is set to FALSE
ST_MinMax('tmax_2010', 'rast', 1)
- ST_MinMax(rastertable text, rastercolumn text, hasnodata boolean) -> record
nband is set to 1
ST_MinMax('precip_2011', 'rast', TRUE)
- ST_MinMax(rastertable text, rastercolumn text) -> record
nband is set to 1 and hasnodata is set to FALSE
ST_MinMax('tmin_2009', 'rast')
Variations for ST_ApproxMinMax are:
- ST_ApproxMinMax(rastertable text, rastercolumn text, nband int, hasnodata boolean, sample_percent double precision) -> record
ST_ApproxMinMax('tmax_2010', 'rast', 1, FALSE, 0.5) ST_ApproxMinMax('precip_2011', 'rast', 1, TRUE, 0.2)
- ST_ApproxMinMax(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> record
hasnodata is set to FALSE
ST_ApproxMinMax('tmax_2010', 'rast', 1, 0.5) ST_ApproxMinMax('precip_2011', 'rast', 1, 0.2)
- ST_ApproxMinMax(rastertable text, rastercolumn text, hasnodata boolean, sample_percent double precision) -> record
nband is set to 1
ST_ApproxMinMax('tmax_2010', 'rast', FALSE, 0.5) ST_ApproxMinMax('precip_2011', 'rast', TRUE, 0.2)
- ST_ApproxMinMax(rastertable text, rastercolumn text, sample_percent double precision) -> record
nband is set to 1 and hasnodata is set to FALSE
ST_ApproxMinMax('tmax_2010', 'rast', 0.5) ST_ApproxMinMax('precip_2011', 'rast', 0.2)
- ST_ApproxMinMax(rastertable text, rastercolumn text) -> record
nband is set to 1, hasnodata is set to FALSE and sample_percent is set to 0.1
ST_ApproxMinMax('tmax_2010', 'rast') ST_ApproxMinMax('precip_2011', 'rast')
by , 13 years ago
Attachment: | st_minmax.5.patch added |
---|
Refactored to depend upon ST_SummaryStats instead of the original function.
comment:10 by , 13 years ago
Adds ST_MinMax function, which builds upon ST_SummaryStats. Merges cleanly against r7145.
The following patches must be merged first for this patch to merge cleanly:
- ST_Band
- ST_SummaryStats
- ST_Mean
- ST_StdDev
comment:11 by , 13 years ago
Keywords: | history added |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Added in r7151
comment:12 by , 13 years ago
Milestone: | PostGIS Raster Future → PostGIS 2.0.0 |
---|
Additional variations of the ST_MinMax function
ST_MinMax(rast raster, nband int, ignore_nodata boolean) -> set of record (min float8, max float8)
ST_MinMax(rast raster, ignore_nodata boolean) -> set of record (min float8, max float8)
The prior two versions of the function
ST_MinMax(rast raster, nband int) -> set of record
ST_MinMax(rast raster) -> set of record
will also assume that ignore_nodata is TRUE.