Version 122 (modified by 13 years ago) ( diff ) | ,
---|
PostGIS Raster Working Specifications for Future Versions
Quick Links
Note that accomplished objectives have been moved at the bottom of the page.
Objective FV.02 - Being able to intersect vector and raster to produce raster.
ST_Intersects(raster, raster)
ST_AsRaster(geometry, pixelsize) → raster
ST_Intersection(geometry, val, raster, band) → raster
The first series of variant return a raster having the same extent as the provided raster.
Variant 1: ST_Intersection(geometry, val, raster, band, pixeltype, nodatavalue) → raster
Variant 2: ST_Intersection(raster, band, geometry, val, pixeltype, nodatavalue) → raster
Variant 3: ST_Intersection(geometry, val, raster, pixeltype, nodatavalue) → raster
Variant 4: ST_Intersection(raster, geometry, val, pixeltype, nodatavalue) → raster
The second series of variant return a raster having the minimal extent.
Variant 5: ST_Intersection(geometry, val, raster, band, pixeltype, nodatavalue, 'TRIM') → raster
Variant 6: ST_Intersection(raster, band, geometry, val, pixeltype, nodatavalue, 'TRIM') → raster
Variant 7: ST_Intersection(geometry, val, raster, pixeltype, nodatavalue, 'TRIM') → raster
Variant 8: ST_Intersection(raster, geometry, val, pixeltype, nodatavalue, 'TRIM') → raster
Returns a two bands raster the first band containing only the pixels from the provided raster intersecting with the geometry and the second band containing the same area filled with the provided value.
The second band gets its pixeltype and nodatavalue from the parameters.
Non intersecting pixels are filled with nodata values.
Variant 1 return a raster having the same extent as the provided raster.
Variant 3, 4, 7 and 8 defaults the band number to 1.
Variant 5 to 8 "trim" or "crop" the raster to the withvalue extent (removing extra nodata value pixels surrounding the extent of the resulting withvalue extent).
Open question
PR: Shoud we return one raster per raster/geometry couple or split the raster into as many small rasters as there are areas sharing a same value? The second behavior seems more coherent with the present behavior of ST_Intersection(raster, geometry) → geometry even if this would produce tons of small two bands rasters.
Implementation details
Rasterize the geometry as a new raster (ST_AsRaster(geometry, pixeltype, val, nodataval, raster)) and then copy only pixels for which both raster bands have a value. Should be implemented as a wrapper around ST_MapAlgebra after rasterizing the geometry to a raster having the same alignment as the raster.
Objective FV.03 - Implement all the necessary versions of ST_MapAlgebra
Different versions of ST_MapAlgebra are planned…
One raster versions:
1) ST_MapAlgebraExpr() - A one raster version taking an expression of one pixel at a time. Already implemented…
2) ST_MapAlgebraFct() - A one raster version taking a user defined function (with optional parameters) of one pixel at a time. The function is a user defined PL/pgSQL function taking a float8 value and returning a value. Code was developped by David Zwarg, needs to be integrated in the source tree. This version is much faster than 1) but requires the user to write a PL/pgSQL function.
3) ST_MapAlgebraFctNgb() - A one raster version taking a user defined function (with optional parameters) of the set of first, second, etc… neighbours of a pixel. The function is a user defined PL/pgSQL function taking a matrix containing the neighbour values and returning one value. Code do not exist yet but will be very much similar to 2). Out of bound pixels values are set to NULL. This version requires the user to write a PL/pgSQL function. Many predefined function should be delivered.
4) ST_MapAlgebraFctNgb() - A one raster version taking a table name and a raster column name (in order to work on a tiled coverage) and a user defined function (with optional parameters) of the set of first, second, etc… neighbours of a pixel. The passed matrix should include values for out of bound pixels taken from neighbour tiles.
Two rasters versions. These versions must take into account different alignment, different extents, nodata and non-existent values.
5) ST_MapAlgebraExpr() - A two rasters version taking an expression of two pixels at a time, one from each rasters.
6) ST_MapAlgebraExpr() - A two rasters version taking a table name and a raster column name (in order to work on a tiled coverage) and an expression of two pixels at a time, one from each rasters.
7) ST_MapAlgebraFct() - A two rasters version taking a user defined function (with optional parameters) of two pixels at a time, one from each rasters. The function is a user defined PL/pgSQL function taking two float8 values and returning one value.
8) ST_MapAlgebraFct() - A two rasters version taking a table name and a raster column name (in order to work on a tiled coverage) and a user defined function (with optional parameters) of two pixels at a time, one from each rasters. The function is a user defined PL/pgSQL function taking two float8 values and returning one value. Non-existent values are found in the neighbour tiles when possible.
Parameters and details for each variant follow…
Details for 1) ST_MapAlgebraExpr(raster rast, integer band, text expression, text nodatavalueexpr, text pixeltype) → raster
This function is already implemented. See the specifications of Objective 2.0.02 and the documentation.
Details for 3) ST_MapAlgebraFctNgb()
For now ST_MapAlgebra expressions refer only to the pixel being computed. e.g. "rast * 100". The original plan was to allow refering to neighbour pixels using two coordinated relative to the pixel being computed. e.g. "rast[-1,0] * 100" where rast[-1,0] refer to the value of the pixel one pixel to the left of the pixel being computed. However this syntax might prove to be hard to use when many neighbours are to be used.
An alternative syntax would involve another function name (e.g. ST_MapAlgebraNgb or ST_MovingWindow) and a way to define a neighbour rectangular region around the computed pixel (e.g.: "2,2" meaning a rectangle encompassing the two neighbour pixels in each direction) and a function to call with this matrix of pixel values. A complete example might look like:
SELECT ST_MapAlgebraNgb(rast, band, pixeltype, "ST_Mean", 2, 2, "ignore")
So this would mean "for each pixel, compute the average of all the 1 + 8 + 16 = 25 pixels surrounding the current pixel and "ignore" pixels with nodata values."
The "ST_Mean" summarizing function should accept three parameters: an array of float8 values, a X and a Y dimension, and optionnally a "what to do with nodata values". The possible value for this last parameter could be:
-"NULL": If any value is a nodata value, return NULL.
-"ignore": Ignore any nodata value so that if 4 pixels on 25 are nodata values, do the computation with the 21 remaining. This is the default.
-"value": Replace any nodata value with the value of the pixel being computed.
-a value: Replace any nodata value with this value and compute.
Any remaining parameters to ST_MapAlgebraNgb could be passed to the summarizing functions for its own need (e.g. "round" to specify that only the pixel forming a circle should be used in the computing).
A number of predefined summarizing function could be delivered: ST_Max, ST_Min, ST_Sum, ST_Distinct, ST_Mean, ST_STD, ST_Range, ST_Quantile, ST_Median, ST_Majority, ST_Minority, ST_Slope, ST_Aspect, and more…
Users could write their own map algebra summarizing functions.
A more sophisticated version would pass a georeferenced raster instead of just a value matrix so that summarizing function could use this geoereference (e.g. to determine a value from the whole coverage (with ST_Value) when the neighbours are out of the bound of the raster). Passing a raster would allow existing raster functions (like the summarizing function which are to come). Only the optional "what to do with nodata values" could be needed and some additional parameters. In this case the example become:
SELECT ST_MapAlgebraNgb(rast, band, pixeltype, 2, 2, "ST_Mean", "ignore")
and the dimensions do not have to be passed to the summarizing functions since it could deduce them from ST_Width & ST_Height.
An even more sophisticated version should get a raster table and a raster column as parameters and try to search for neighbour in the whole raster coverage when out of bound pixels are part of the neighbourhood. e.g.:
SELECT ST_MapAlgebraNgb("mycoveragetable", "myrastercolumn", band, pixeltype, 2, 2, "ST_Mean", "ignore")
Three difficulties must be solved to implement this function:
-The construction of the matrix must to be passed to the summarizing functions must be optimized when passing from one pixel to the other.
-We must see how it is possible to call a PL/pgSQL function from a C function
-We must see how to pass a variable number of parameter to a PL/pgSQL function
See also: Notes taken by David Zwarg during the Montreal Code Sprint 2011 and http://trac.osgeo.org/postgis/ticket/860
Details for 5) to 8) Two rasters versions
Specifications of two rasters versions of ST_MapAlgebra are still in progress as a new optimised version, filling large areas of same value more quickly and dependent on ST_SetValues() described in Objective 2.0.05, is planned. See http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql/st_mapalgebra_optimized.sql The idea is to set large areas of the resulting raster when possible using a process more similar to memcpy than by computing one pixel value at a time.
-Both rasters must have the same SRID. If not, ST_MapAlgebra should return an error: "ERROR: Operation on two geometries with different SRIDs"
-Both raster must be aligned. This is determined using the ST_SameAlignment() function described below. If a resampling is necessary they use the planned ST_Resample() function to resample the second raster to the first one before processing (or the first to the second if an optional parameter is provided). If ST_Resample() is not yet implemented when these functions are implemented, just return an error message: "ERROR: MapAlgebra on rasters with different alignment not yet implemented."
-Both raster must overlap. This is determined using ST_Intersects(raster, raster) (to be implemented). If they don't overlap an empty raster is returned.
One of the implications of this is that users should add a WHERE clause to avoid useless computation with non-overlapping rasters. This is the same principle as with ST_Intersection(). Hence:
SELECT ST_MapAlgebra(rast1, rast2, mathExpr) FROM mytable WHERE ST_Intersects(rast1, rast2)
will be faster than:
SELECT ST_MapAlgebra(rast1, rast2, mathExpr) FROM mytable
-The computation extent (extentexpr in the functions below) can be:
-'FIRST' (the extent of the first raster),
-'SECOND' (the extent of the first raster),
-'INTERSECTION' (the extent of the intersection of both rasters),
-'UNION' (the extent of the union of both rasters).
Replacement expressions can be provided as parameter for when:
-The first raster value is nodata (nodata1expr in the functions below)
-The second raster value is nodata (nodata2expr in the functions below)
-Both rasters values when they are both nodata (nodatanodataexpr in the functions below)
Open Question 1 (DZ): Should ST_MapAlgebra resample the resulting rasters internally, or should we let the users resample it afterward with ST_Resample: ST_Resample(ST_MapAlgebra(), originx, originy, pixelsizex, pixelsizey)
PR: I think this would greatly contribute to simplify the API.
Details for 5) ST_MapAlgebraExpr(rast1 raster, band1 integer, rast2 raster, band2 integer, expression text, pixeltype text, extentexpr text, nodata1expr text, nodata2expr text, nodatanodataexpr text) → raster
See discussion in http://trac.osgeo.org/postgis/ticket/590
Details for ST_SameAlignment(raster, raster)
This function returns true if both rasters' grids are aligned.
Two rasters grid are aligned if:
-They share the same pixel scales and skews
-At least one of any of the four corner of any pixel of one raster fall on any corner of the grid of the other raster.
Alignment is not the same concept as georeference. Two rasters can be aligned but not have the same georeference.
Rotation is important here since two rasters grid might look perfectly aligned but are not if their rotated are different.
Knowing if two rasters share the same alignment is useful when it is time to decide if one of them must be resampled before doing other operations (like ST_MapAlgebra on two rasters).
Variants
1) ST_SameAlignment(ulx1, uly1, scalex1, scaley1, skewx1, skewy1, ulx2, uly2, scalex2, scaley2, skewx2, skewy2)
2) ST_SameAlignment(rast1 raster, rast2 raster)
The first variant is useful to PL/pgSQL function which have already get the values of the parameters.
Implementation Details
Only the first variant should be implemented in C. The second one is a PL/pgSQL variants. The C implementation should follow the PL/pgSQL version implemented in http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql/st_mapalgebra.sql
It is not clear if this PL/pgSQL implementation works when raster are rotated. To verify.
See discussion in http://trac.osgeo.org/postgis/ticket/589
Objective FV.04 - Being able to use "group by" to accumulate tiles to form a new raster.
ST_Union(raster|geometry, raster|geometry, 'raster'|'geometry') → raster/geometry
ST_Accum(raster set|geometry set, 'raster'|'geometry') → raster/geometry
Objective FV.06 - Being able to do some base raster operations.
ST_Area(raster|geometry) → double
ST_ValueCount(raster, value) → integer - done see below
ST_ValuePercent(raster, value) → double precision - done see below
ST_Resample(raster, method, originx, originy, pixelsizex, pixelsizey) → raster
Variant
1) ST_Resample(raster, method, raster) → raster
Recompute a raster in order to change its pixel size and/or the position of its upper left corner.
The second parameter is the resampling method performed when computing new pixel values:
1) 'NEAREST NEIGHBOR'
2) 'LINEAR'
3) 'BICUBIC'
The 3rd or 3rd-6th parameters define the pixel size of the resampling operation. For the 3rd parameter variant, the pixel size is taken from the pixel size of the raster parameter. For the 3rd-6th parameter variant, the pixel origin and dimensions are explicitly defined.
ST_SelectByValue(raster|geometry, 'expression') → same type as first argument
ST_Clip(raster|geometry,geometry) → same type as first argument
ST_Flip(raster|geometry, 'vertical'|'horizontal') → same type as first argument
Objective FV.07 - Being able to convert a raster to standards formats.
ST_AsKML(raster|geometry) → string
ST_AsSVG(raster|geometry) → string
Objective FV.08 - Being able to control the validity of a raster.
ST_mem_size(raster|geometry) → integer
ST_isvalid(raster|geometry) → boolean
Objective FV.09 - Being able to use other major topological operators
ST_Within(raster|geometry A, raster|geometry B)
ST_Contains(raster|geometry A, raster|geometry B)
ST_Overlaps(raster|geometry, raster|geometry)
Objective FV.10 - Being able to derive a raster layer from vector layer.
ST_Interpolate(points, pixelsize, method) → raster
Objective FV.11 - Being able to do on rasters most operations available on geometries
ST_Centroid(raster|geometry) → point geometry
ST_PointOnSurface(raster|geometry) → point geometry
ST_Buffer(raster|geometry, double) → same type as first arg.
ST_Difference(raster|geometry A, raster|geometry B) → same type as first argument
ST_SymDifference(raster|geometry,raster|geometry,'raster'|'geometry') → raster/geometry
Objective FV.12 - Being able to use all the other topological operators
ST_Equals(raster|geometry, raster|geometry)
ST_Disjoint(raster|geometry, raster|geometry)
ST_Touches(raster|geometry, raster|geometry)
ST_Crosses(raster|geometry, raster|geometry)
ST_Covers(raster|geometry A, raster|geometry B)
ST_IsCoveredBy(raster|geometry A, raster|geometry B)
ST_Relate(raster|geometry, raster|geometry, intersectionPatternMatrix )
Objective FV.13 - Being able to edit a raster
ST_Affine(raster|geometry, …) → same type as input
ST_Translate(raster|geometry, …) → same type as input
ST_Scale(raster|geometry, …) → same type as input
ST_TransScale(raster|geometry, …) → same type as input
ST_RotateZ,Y,Z(raster|geometry, float8) → same type as input
Objective FV.14 - Being able to intersect two rasters to get a raster.
ST_Intersection(raster, integer, raster, integer) → raster - Returns a two bands raster with values only in the intersecting areas of both rasters. Integer parameters are the band number of the raster.
Variants
1) ST_Intersection(raster, integer, raster, integer) → raster — the integer parameters are the band number of the rasters
2) ST_Intersection(raster, raster, integer) → raster — default first raster to band # 1
3) ST_Intersection(raster, integer, raster) → raster — default second raster to band # 1
4) ST_Intersection(raster, raster) → raster — default both rasters to band # 1
Objective FV.15 - Being able to intersect two rasters to get a geometry.
ST_Intersection(raster, integer, raster, integer, 'geometry') → geometry - Returns a two bands raster with values only in the intersecting areas of both rasters. Integer parameters are the band number of the raster.
Variants
1) ST_Intersection(raster, integer, raster, integer, 'geometry') → geometry
2) ST_Intersection(raster, raster, integer, 'geometry') → geometry — default first raster to band # 1
3) ST_Intersection(raster, integer, raster, 'geometry') → geometry — default second raster to band # 1
4) ST_Intersection(raster, raster, 'geometry') → geometry — default both raster to band # 1
Objective FV.17 - Being able to refer to band by textual name.
Add 8 digit string to each band in the base raster WKB format.
Adjust gdal2wktraster.py to be able to give names to each band when importing.
Adjust/overlaod every function to be able to refer to raster band by name.
Objective FV.18 - Being able to load rasters from SQL
The idea is to change the rt_band_get_data core function so it load filesystem registered raster data using GDAL into the data base. This allow us to create a list of raster with a new ST_MakeRegisteredRaster("c:/temp/mytiff/*.tif") and to convert them witinot a CREATE TABLE with a ST_MakeBandInDB(rast, band)
Changes to the rt_band_get_data core function
ST_MakeRegisteredRaster(wildcardPath)
ST_SetPath(raster, band, string)
ST_MakeBandInDB(rast, band)
Other functions
ST_AsBinary(raster, compression)
ST_RasterFromWKB(raster, [<srid>])
ST_RasterFromText(string, [<srid>])
ST_AsText(raster)
Accomplished objectives
Objective FV.01 - Being able to return a JPEG, a TIFF, a PNG or any image format supported by GDAL - Done
ST_bytea(raster, integer) → raster — the integer parameters is the band number of the raster.
What is does?
Open Question: When exporting a multiband raster to JPEG, TIFF, PNG, SVG or KML, how should we specify the band number in the exporting function.
There is two options to select the band to convert from a multiband raster in all the ST_AsFormat functions.
1. Precede each call with ST_Band() to return a selected band.
Pros: This is a general function that can be called before any function that would otherwise require a band parameter.
Cons: This implies creating a temporary raster. This might be more elegant and general but is this too much overhead comparing with having a band parameter?
2. Add a band parameter to each ST_AsFormat function.
Pros: Hypothetically less overhead.
Cons: Every functions implying access to a band should then have this parameter when in most case it would be equal to 1. In many cases it makes no sence to have to specify a band parameter since it is the whole raster that we want to export, including all the bands.
Pierre: More I think about it more I think that the first option is the best one…
mloskot: Perhaps there is a compromise in form of two sets of functions: 1) ST_As* which always burn the whole raster (all bands) 2) ST_BandAs* which takes number of band as a parameter and return only this requested band.
ST_Band(raster, integer) → raster — the integer parameters are the band number of the rasters.
Return a single band from a multiband raster. If "band" is greater than the value returned by ST_GetNumBands(), the function returns the last band. This function should be used to select a band before converting it to JPEG, TIFF, PNG, SVG or KML with the corresponding function. e.g. ST_AsTIFF(ST_Band(raster, band))
A complete implementation of ST_Band should include the following:
- ST_Band(rast raster, nbands int[]) → raster
nbands is an array of 1-based band indices of the bands to copy into the output raster
For a raster rast with 3 bands:
ST_Band(rast, ARRAY[1,3,2]) ST_Band(rast, ARRAY[3,2,1])You can rearrange the bands as above. You can also duplicate the bands:
ST_Band(rast, ARRAY[1,2,3,2,1])
- ST_Band(rast raster, nband int) → raster
nband is a single integer of the 1-based band index of the band to copy into the output raster
ST_Band(rast, 1) ST_Band(rast, 3)
- ST_Band(rast raster, nbands text) → raster
nbands is a comma separated string of 1-based band indices indicating the bands to copy into the output raster
ST_Band(rast, '1,2') ST_Band(rast, '1,2,3, 1, 1 , 2')
- ST_Band(rast raster, nbands text, delimiter char) → raster
nbands is a user-specified delimiter separated string of 1-based band indices indicating the bands to copy into the output raster
ST_Band(rast, '1,2', ',') ST_Band(rast, '1,2,3, 1, 1 , 2', ',')
- ST_Band(rast raster) → raster
the band to extract is automatically assumed to be one.
ST_Band(rast)
If an index is outside the valid range of band indices for a raster (less than 1 or greater than the value returned by ST_NumBands), the function will fail and return.
Open Question: Should the function fail if an index is invalid? How should this work when providing more than one indices to the function?
ST_AsJPEG(raster, quality) → JPEG as "bytea"
The JPEG format has several limitations:
- JPEG only allows 1 (greyscale) or 3 (RGB) bands of data
- JPEG only supports 8BUI pixeltype
- JPEG cannot embed spatial reference information within the file but can have an associated world file
To address the limitations:
- Use ST_Band to specify which band(s) should be passed to the ST_AsJPEG function. Variations of ST_AsJPEG are made available that allows specifying a band index. If a raster whose number of specified bands does not equal 1 or 3 is provided, a warning is raised and the first or the first three bands are used.
- Throw an exception if any of the specified bands is not 8BUI. The user should use ST_Reclass to convert any non-8BUI bands to 8BUI.
- Nothing can be done.
A proposed set of variations of the ST_AsJPEG function:
- ST_AsJPEG(rast raster, options text[])
rast: the raster with one or three bands in 8BUI pixel type to generate a JPEG image from
options: array of creation options to pass to the GDAL JPEG driver
ST_AsJPEG(rast, ARRAY['QUALITY=90', 'PROGRESSIVE=ON'])
- ST_AsJPEG(rast raster)
Like #1 above but use the driver's default creation options
- ST_AsJPEG(rast raster, nbands int[], options text[])
nbands: an integer array specifying the band indices of the raster to include in the JPEG file
ST_AsJPEG(rast, ARRAY[1,3,6], ARRAY['QUALITY=50'])
- ST_AsJPEG(rast raster, nbands int[])
Like #3, but use the default creation options
ST_AsJPEG(rast, ARRAY[1,3,6])
- ST_AsJPEG(rast raster, nbands int[], quality int)
quality: number between 10 and 100 indicating image quality
ST_AsJPEG(rast, ARRAY[1,2,3], 90)
- ST_AsJPEG(rast raster, nband int, options text[])
nband: index of the band to include
ST_AsJPEG(rast, 2, ARRAY['QUALITY=25'])
- ST_AsJPEG(rast raster, nband int, quality int)
ST_AsJPEG(rast, 5, 75)
- ST_AsJPEG(rast raster, nband int)
ST_AsJPEG(rast, 4)
OLD NOTES
Return the raster as a JPEG encoded as a PostgreSQL bytea. By default quality is set to 75, but this option can be used to select other values. Values must be in the range 10-100. Low values result in higher compression ratios, but poorer image quality. Values above 95 are not meaningfully better quality but can but substantially larger. (copied from http://www.gdal.org/frmt_jpeg.html)
Open Question: Is JPEG export limited to raster having 8 bit unsigned integer pixeltype (8BUI)?
See how GDAL do it. It converts only 8 bits rasters. Should we do the same?
Otherwise, how do we convert other types to 8BUI? e.g. 16BUI or 8BSI?
Pierre: It might be more simple to ignore pixeltypes other than 8BUI but it would be very convenient to have a way to quickly export elevation data for example as a JPEG. It would be nice to have an elegant solution to this. Maybe something inspired from MapServer.
Proposition one (Pierre): ST_AsJPEG could simply (optionally when the pixeltype is not 8BUI) map the ST_Maximum() and ST_Minimum() value to 0-255. ST_Maximum() and ST_Minimum() are not in the spec yet but this could be on nice usage of it. They will imply caching the min and max when importing and editing. Both function should ignore the NoDataValues. They could also be two parameters passed to ST_AsJPEG(raster, quality, min, max).
Proposition two: There could also be just one parameter (string) defining a mapping method:
* Method "None": No mapping. This is possible only for 8BUI.
* Method "MaxMinValue": Use the Max and the Min cached in the raster. e.g. for 16BSI (min, max) → (-2033, 2456) → (round((-2033 - -2033)/(2456 - -2033)*255), round((2456 - -2033)/(2456 - -2033)*255)) → (0, 255).
This is equivalent to ST_AsJPEG(raster, quality, ST_Minimum(rast), ST_Maximum(rast))
* Method "MaxMinType": Use the Max and the Min allowed by the type. e.g. for 16BSI (min, max) → (-2033, 2456) → (round((-2033 - -32768)/(32767 - -32768)*255), round((2456 - -32768)/(32767 - -32768)*255)) → (120, 137)
This would be equivalent to ST_AsJPEG(raster, quality, ST_BandPixelTypeMin(rast), ST_BandPixelTypeMax(rast)). Both functions (ST_BandPixelTypeMin & ST_BandPixelTypeMax) are not yet planned and I could not find an SQL query that returns the equivalent range for a type. One possible solution.
mloskot: ATM, I have no thoughts on this issue.
Open Question: Is JPEG export limited to raster having 1 or 3 bands?
See how GDAL do it. It converts only 1 or 3 band rasters. Should we do the same? In this case 1 band rasters would be exported as a greyscale JPEG having R G and B identical and 3 band rasters would be interpreted as R, G and B.
Pierre: I think the answer should be yes. I don't see how we could have a 2 band raster fit into RGB.
mloskot: I agree, the answer should be yes.
Here is an attempt to define the different versions of the function:
The most minimalistic versions of the function should assume band 1, 2 and 3 as being r, g, b and the quality equal to 75:
ST_AsJPEG(raster) -quality = 75
A variant allow specifying the quality:
ST_AsJPEG(raster, integer)
Another variant should enable us to specify which band correspond to the r, the g and the b:
ST_AsJPEG(raster, integer, integer, integer) - raster, rband, gband, bband, quality=75
ST_AsJPEG(raster, integer, integer, integer, integer) - raster, rband, gband, bband, quality
Another version should be designed to be used with a future ST_Band(raster) function. In this case there is no attempt to extract r, g or b band from any passed raster:
ST_AsJPEG(raster, raster, raster)
ST_AsJPEG(raster, raster, raster, integer) -with the quality param
Another series should allow converting 1 band raster with pixel of type 8BUI to a grayscale JPEG (Carefull study of the GDAL behavior when converting a single band to JPEG should be done before confirming these functions):
ST_AsJPEG(raster, "GRAYSCALE") - convert only band 1 with quality = 75
ST_AsJPEG(raster, "GRAYSCALE", integer) - convert only band 1 with specified quality
ST_AsJPEG(raster, integer, "GRAYSCALE") - allow specifying the band number to convert
ST_AsJPEG(raster, integer, "GRAYSCALE", integer) - allow specifying the band number to convert and the quality
Another series should allow converting 1 band raster of ANY pixel type to a grayscale JPEG. Pixel types different than 8BUI should be mapped according to specified min, max values and a mapping mode: "MaxMinValue" (default) or "MaxMinType".
ST_AsJPEG(raster, "GRAYSCALE", min, max, text) - convert only band 1 with quality = 75
ST_AsJPEG(raster, "GRAYSCALE", integer, min, max, text) - convert only band 1 with specified quality
ST_AsJPEG(raster, integer, "GRAYSCALE", min, max, text) - allow specifying the band number to convert
ST_AsJPEG(raster, integer, "GRAYSCALE", integer, min, max, text) - allow specifying the band number to convert and the quality
ST_AsTIFF(raster, compression) → TIFF as "bytea"
Return the raster as a TIFF encoded as a PostgreSQL bytea. If raster is a multiband raster and no band were selected with ST_Band() every band are written to the resulting TIFF.
compression=[JPEG/LZW/PACKBITS/DEFLATE/CCITTRLE/CCITTFAX3/CCITTFAX4/NONE]: Set the type of compression to use. None is the default. The CCITT compression should only be used with 1bit (NBITS=1) data. JPEG should only be used with Byte data. When using JPEG add a number specifying the quality. 75 is the default. e.g. ST_AsTIFF(raster, "JPEG60") (copied from http://www.gdal.org/frmt_gtiff.html)
A proposed implementation of the ST_AsTIFF functions.
The TIFF format is probably the most robust available for converting rasters to GDAL rasters. Not only does it support all PostGIS Raster pixel types, it also provides plenty of creation options and possibly no issues with the number of bands. The only limitation found is that there can only be one NODATA value for all bands.
If the compression parameter/option is specified to JPEG, all bands must be of pixel type 8BUI. If the compression parameter/option is specified to one of the CCITT options, all bands must be of pixel type 1BB. If any band violates the restriction, an exception is raised.
The next three functions are the most basic of the ST_AsTIFF functions.
- ST_AsTIFF(rast raster, options text[], srs text) → bytea
The most generic version of this function. All other ST_AsTIFF functions call this function.
This function will check that all bands of the raster to be converted has the same NODATA value. If there are more than one possible NODATA values, a WARNING will be raised and the output TIFF will use the NODATA value of the first band with a NODATA value.
options: the GDAL creation options found in the Creation Options section of the GDAL TIFF driver
srs: the user-specified OGC WKT or the proj4 text for a spatial reference to embed in the GDAL raster. TIFF is one of the formats that supports embedding the spatial reference within the image file.
ST_AsTIFF(rast, ARRAY['COMPRESS=DEFLATE', 'ZLEVEL=9'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs') ST_AsTIFF(rast, ARRAY['COMPRESS=DEFLATE', 'ZLEVEL=9'], 'PROJCS["NAD83 / California Albers",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["standard_parallel_1",34],PARAMETER["standard_parallel_2",40.5],PARAMETER["latitude_of_center",0],PARAMETER["longitude_of_center",-120],PARAMETER["false_easting",0],PARAMETER["false_northing",-4000000],AUTHORITY["EPSG","3310"],AXIS["X",EAST],AXIS["Y",NORTH]]')
- ST_AsTIFF(rast raster, options text[]) → bytea
This one removes the user-specified srs argument. The output TIFF's spatial reference will be set to the same as the input raster, if possible.
ST_AsTIFF(rast, ARRAY['COMPRESS=DEFLATE', 'ZLEVEL=9'])
- ST_AsTIFF(rast raster) → bytea
The simplest implementation of this function. Since the options argument has been removed, the output TIFF will be created with default options. Like the prior function, the spatial reference of the TIFF will be set to the same as the input raster.
ST_AsTIFF(rast)
The next three functions add a band index argument to filter the raster's bands before generating the output TIFF.
- ST_AsTIFF(rast raster, nbands int[], options text[], srs text) → bytea
ST_AsTIFF(rast, ARRAY[3,1,2], ARRAY['COMPRESS=DEFLATE', 'ZLEVEL=9'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
- ST_AsTIFF(rast raster, nbands int[], options text[]) → bytea
This one removes the user-specified srs argument. The output TIFF's spatial reference will be set to the same as the input raster, if possible.
ST_AsTIFF(rast, ARRAY[3,1,2], ARRAY['COMPRESS=DEFLATE', 'ZLEVEL=9'])
- ST_AsTIFF(rast raster, nbands int[]) → bytea
Since the options argument has been removed, the output TIFF will be created with default options. Like the prior function, the spatial reference of the TIFF will be set to the same as the input raster.
ST_AsTIFF(rast, ARRAY[3,1,2])
The next two functions add a compression argument. If the compression desired is JPEG or DEFLATE, the user can specify a quality as part of the compression string.
Examples are:
JPEG90 JPEG DEFLATE8 DEFLATE
- ST_AsTIFF(rast raster, compression text, srs text) → bytea
This function will parse the compression string for the compression type and the compression quality. It will also inspect to make sure that the pixel types of the raster's bands are appropriate for the compression type. This is primarily for JPEG and CCITT compression types, which only support 8BUI and 1BB respectively.
ST_AsTIFF(rast, 'JPEG90', '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs') ST_AsTIFF(rast, 'JPEG', '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs') ST_AsTIFF(rast, 'LZMA', '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
- ST_AsTIFF(rast raster, compression text) → bytea
The output TIFF will be created with default options. Like the prior function, the spatial reference of the TIFF will be set to the same as the input raster.
ST_AsTIFF(rast, 'LZMA')
The next two functions include band index and compression arguments
- ST_AsTIFF(rast raster, nbands int[], compression text, srs text) → bytea
ST_AsTIFF(rast, ARRAY[2], 'JPEG90', ARRAY['BIGTIFF=IF_NEEDED'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs') ST_AsTIFF(rast, ARRAY[1,3], 'JPEG', ARRAY['BIGTIFF=IF_NEEDED'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs') ST_AsTIFF(rast, ARRAY[3,1,2], 'LZMA', ARRAY['BIGTIFF=IF_NEEDED'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs')
- ST_AsTIFF(rast raster, nbands int[], compression text) → bytea
ST_AsTIFF(rast, ARRAY[3,2], 'DEFLATE9')
The output TIFF will be created with default options. The spatial reference of the TIFF will be set to the same as the input raster.
Open Question: What if we want to export only the first two band of a three band layer?
Maybe we need a ST_RasterFromBands(band1, band2, etc…) to reconstitute a multiband raster from multiple sources (having the same width, height, pixelsize, etc…)
mloskot: or ST_RasterFromBands(bands) where bands is ARRAY[int]. For instance, ST_RasterFromBands(ARRAY[1,3]) will burn new raster from 1 and 3 bands of input raster.
ST_AsPNG(raster, band) → PNG as "bytea"
Like the JPEG raster format, the PNG format has limitations:
- PNG only allows 1 (greyscale) or 3 (RGB) bands of data
- PNG only supports 8BUI and 16BUI pixeltypes. Any other pixeltype will be written as 8BUI, though the results are probably useless
- PNG cannot embed spatial reference information within the file but can have an associated world file
Like JPEG, the limitations can be resolved:
- Use ST_Band to specify which band(s) should be passed to the ST_AsPNG function. If a raster whose number of specified bands does not equal 1 or 3 is provided, a warning is raised and the first or the first three bands are used.
- Throw an exception if any of the specified bands is not 8BUI or 16BUI. The user should use ST_Reclass to convert any non-8BUI or 16BUI bands to 8BUI or 16BUI.
- Nothing can be done within this function. ST_Georeference() can be used to the contents of the associated world file
A proposed set of variations of the ST_AsPNG function:
- ST_AsPNG(rast raster, options text[])
rast: the raster with one or three bands in 8BUI or 16BUI pixel type to generate a PNG image from
options: array of creation options to pass to the GDAL PNG driver
ST_AsPNG(rast, ARRAY['ZLEVEL=9'])
- ST_AsPNG(rast raster)
Like #1 above but use the driver's default creation options
- ST_AsPNG(rast raster, nbands int[], options text[])
nbands: an integer array specifying the band indices of the raster to include in the PNG file
ST_AsPNG(rast, ARRAY[3,1,2], ARRAY['ZLEVEL=9'])
- ST_AsPNG(rast raster, nbands int[])
Like #3, but use the default creation options
ST_AsPNG(rast, ARRAY[3])
- ST_AsPNG(rast raster, nbands int[], compression int)
compression: number between 1 and 9 indicating the amount of time to spend on compression. 1 is fastest with least compression. 9 is slowest with best compression
ST_AsPNG(rast, ARRAY[2,1,3], 3)
- ST_AsPNG(rast raster, nband int, options text[])
nband: index of the band to include
ST_AsPNG(rast, 2, ARRAY['ZLEVEL=5'])
- ST_AsPNG(rast raster, nband int, compression int)
ST_AsPNG(rast, 1, 8)
- ST_AsPNG(rast raster, nband int)
ST_AsPNG(rast, 1)
ST_AsGDALRaster(raster, band int, type text, options text) → bytea
Use GDAL to convert the raster into one of the format suported by GDAL.
This is a generic interface to outputting a supported and installed GDAL raster:
- ST_AsGDALRaster(rast raster, format text, options text[], srs text) → bytea
This is the most generic and GDAL-specific method to convert a raster to a GDAL raster. All other version of ST_AsGDALRaster and other format specific functions (ST_AsJPEG, ST_AsTIFF and ST_AsPNG) are all wrappers around this function. Reference information for the format and options arguments of a particular format are specified at: http://gdal.org/formats_list.html. The arguments specified are:
format: the GDAL format code. e.g. GTiff, JPEG, PNG
options: the GDAL creation options found in the Creation Options section of a specified format. e.g. COMPRESS=JPEG, JPEG_QUALITY=90
srs: the user-specified OGC WKT or the proj4 text for a spatial reference to embed in the GDAL raster. Not all formats support embedding this information. e.g. the non-empty value for the srtext or proj4text column from the spatial_ref_sys table.
ST_AsGDALRaster(rast, 'GTiff', ARRAY['COMPRESS=JPEG', 'JPEG_QUALITY=90'], '+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs') ST_AsGDALRaster(rast, 'GTiff', ARRAY['COMPRESS=JPEG', 'JPEG_QUALITY=90'], 'PROJCS["NAD83 / California Albers",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["standard_parallel_1",34],PARAMETER["standard_parallel_2",40.5],PARAMETER["latitude_of_center",0],PARAMETER["longitude_of_center",-120],PARAMETER["false_easting",0],PARAMETER["false_northing",-4000000],AUTHORITY["EPSG","3310"],AXIS["X",EAST],AXIS["Y",NORTH]]')
- ST_AsGDALRaster(rast raster, format text, options text[]) → bytea
This one removes the user-specified srs argument. The output GDAL raster's spatial reference will be set to the same as the input raster, if possible.
ST_AsGDALRaster(rast, 'JPEG', ARRAY['QUALITY=50']) ST_AsGDALRaster(rast, 'PNG', ARRAY['ZLEVEL=7'])
- ST_AsGDALRaster(rast raster, format text) → bytea
The simplest implementation of this function. Since the options argument has been removed, the output GDAL raster will be created with default options. Like the prior function, the spatial reference of the GDAL raster will be set to the same as the input raster.
ST_AsGDALRaster(rast, 'JPEG')
ST_GDALDrivers() → set of record
As each GDAL installation may be different and ST_AsGDALRaster can be used to support formats other than GTiff, JPEG and PNG, a method is needed to expose to the end user the possible GDAL formats capable of being exported. This function will output the following columns.
idx: the internal GDAL index number
short_name: the GDAL format code. This is the value to pass to the format paramenter of ST_AsGDALRaster
long_name: the full name of the GDAL format
create_options: the creation options available for the format as an XML string.
The formats outputted from ST_getGDALDrivers have been filtered to only those that the GDAL capabilities CreateCopy and Virtual IO support.
Open Question: Should the GDAL raster process be capable of supporting the GDAL capability Create? As the GDAL raster process writes nothing to a file in the filesystem (via Virtual IO), should there be support for writing the output GDAL raster temporarily to the filesystem? If so, how is it done in other PostgreSQL extensions in a secure manner?
ST_srtext(rast raster) → text
A helper function to get the value of column srtext or proj4text for a raster with an SRID. By default, the srtext is returned. If srtext is not available but proj4text is, the proj4text is returned.
This function may be removed based upon the capabilities of SPI. It may not be possible to remove this function as the srs function argument of ST_AsGDALRaster can be NULL, thereby instructing the function to not embed any spatial reference information into the output GDAL raster.
ST_Reclass(rast raster, VARIADIC argset reclassarg[]) → raster
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. 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.
ST_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.
- ST_Reclass(rast raster, VARIADIC argset reclassarg[]) → raster
rast: the raster whose specified bands are to be reclassified
reclassarg: a new custom type defining the parameters required for reclassifying a band's pixel values.
CREATE TYPE reclassarg AS ( nband int, reclassexpr text, pixeltype text, nodata double );
nband: index of the band to reclass (1-based)
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.
rangefrom:rangeto[, rangefrom:rangeto]
0-100:0-10 0-100:0-10, 101-1000:11-100 0-100:0-10, 101-1000:11-100, 1001-10000:101-1000
In the last example above, the default evaluation of the ranges is
0 <= x < 100 reclassified to 0 <= y <= 10 101 <= x < 1000 reclassified to 11 <= y <= 100 1001 <= x < 10000 reclassified to 101 <= y <= 1000
To change the evaluation of rangefrom, use square brackets and parentheses.
1. [a-b] = a <= x <= b 2. (a-b] = a < x <= b 3. [a-b) = a <= x < b 4. (a-b) = a < x < b
#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.
[a-b = a <= x < b (a-b = a < x < b a-b] = a <= x <= b a-b) = a <= x < b
Two special cases are also available for use when x may be outside the range of a-b. This situation is possible if your range is based upon an approximation, such as from ST_ApproxMinMax.
]a-b or )a-b = x < a, rule matches a-b[ or a-b( = x >= b, rule matches
pixeltype: the reclassified band's pixel type, e.g. 8BUI, 16BUI, 32BF
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.
ST_Reclass(rast, ROW(1, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', NULL)); ST_Reclass(rast, ROW(1, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', 1001)); ST_Reclass(rast, ROW(1, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', 1001), ROW(2, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', 1001), ROW(3, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', 1001), ROW(5, '0-100:0-10, 101-1000:11-100, 1001-10000:101-1000', '16BUI', 1001) )
An expanded example
SELECT ST_Reclass( ST_Band(rast, ARRAY[1,1,1]), ROW(1, LEAST(covmin, 0)::text || '-0:0,0-' || GREATEST(covmax, 0)::text || ':0-255', '8BUI'), ROW(2, LEAST(covmin, 0)::text || '-0:200,0-' || GREATEST(covmax, 0)::text' || ':0-255','8BUI'), ROW(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') ) FROM mycoverage
- ST_Reclass(rast raster, nband int, reclassexpr text, pixeltype text, nodata double) → raster
provides a method to process just one band of a raster
ST_Reclass(rast, 1, '0-100:0-10', '8BUI', 11)
- ST_Reclass(rast raster, nband int, reclassexpr text, pixeltype text) → raster
nodata parameter removed so reclassified band will NOT have a nodata value set
ST_Reclass(rast, 1, '0-100:0-10', '8BUI')
- ST_Reclass(rast raster, reclassexpr text, pixeltype text) → raster
nband parameter removed so reclassified band is assumed to be 1. nodata parameter removed so reclassified band has NO nodata value.
ST_Reclass(rast, '0-100:0-10', '8BUI')
- ST_Reclass(rast raster, reclassexpr text, pixeltype text, nodata double) → raster
nband parameter removed so reclassified band is assumed to be 1
ST_Reclass(rast, '0-100:0-10', '8BUI', 11)
Objective FV.16 - Being able to quickly get raster statistics. - Done
Add cached basic raster statistic to the base raster WKB format.
Statistics to be cached should include:
min/max
mean
standard deviation
histogram
build parameters of stats (sample rate, method used to determine # of bins in histogram?)
How are the statistics to be kept fresh? Automatically using some method to see how much of the raster has changed since the last stats calculation? Or let the user decide?
ST_SummaryStats(raster, nband) → record
This is the core function that gets the summary statistics (# of values, mean, standard deviation, minimum value, maximum value) of a specified raster's band. It is this function that ST_Mean, ST_StdDev and ST_MinMax calls for their appropriate values.
- ST_SummaryStats(rast raster, nband int, exclude_nodata_value boolean) → record
returns one record of five columns (count, mean, stddev, min, max)
nband: index of band
exclude_nodata_value: if FALSE, nodata values in band are included in the stats. if TRUE, nodata values are not included
ST_SummaryStats(rast, 1, FALSE)
- ST_SummaryStats(rast raster, nband int) → record
assumes exclude_nodata_value = TRUE
ST_SummaryStats(rast, 2)
- ST_SummaryStats(rast raster, exclude_nodata_value boolean) → record
assumes nband = 1
ST_SummaryStats(rast, TRUE)
- ST_SummaryStats(rast raster) → record
assumes nband = 1 and exclude_nodata_value = TRUE
ST_SummaryStats(rast)
Due to the time it may take to do on-the-fly calculation of summary stats for large rasters (say 10000 x 10000), an alternative that sacrifices accuracy for speed is required. The following functions sample a percentage of the raster in a methodical randomized manner. The algorithm used for sampling is…
- select the larger dimension of the width and height. compute the number of pixels to sample in each "row" of the larger dimension
- pick pixels from each "row" of the larger dimension in an incremental rolling manner where each increment is randomly determined.
The set of ST_ApproxSummaryStats functions are:
- ST_ApproxSummaryStats(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) → record
sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
ST_ApproxSummaryStats(rast, 3, FALSE, 0.1) ST_ApproxSummaryStats(rast, 1, TRUE, 0.5)
- ST_ApproxSummaryStats(rast raster, nband int, sample_percent double precision) → record
assumes that nband = 1
ST_ApproxSummaryStats(rast, 2 0.01) ST_ApproxSummaryStats(rast, 4, 0.025)
- ST_ApproxSummaryStats(rast raster, exclude_nodata_value boolean, sample_percent double precision) → record
assumes that nband = 1
ST_ApproxSummaryStats(rast, FALSE, 0.01) ST_ApproxSummaryStats(rast, TRUE, 0.025)
- ST_ApproxSummaryStats(rast raster, sample_percent double precision) → record
assumes that nband = 1 and exclude_nodata_value = TRUE
ST_ApproxSummaryStats(rast, 0.25)
- ST_ApproxSummaryStats(rast raster) → record
assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxSummaryStats(rast)
The situation arises where the summary statistics of a coverage table is required. As the coverage may be large (tens of gigabytes of memory or larger), the following functions are provided to permit an incremental computation of the summary statistics.
- ST_SummaryStats(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) → record
rastertable: name of table with raster column
rastercolumn: name of column of data type raster
ST_SummaryStats('tmax_2010', 'rast', 1, FALSE) ST_SummaryStats('precip_2011', 'rast', 1, TRUE)
- ST_SummaryStats(rastertable text, rastercolumn text, nband int) → record
exclude_nodata_value = TRUE
ST_SummaryStats('tmax_2010', 'rast', 1)
- ST_SummaryStats(rastertable text, rastercolumn text, exclude_nodata_value boolean) → record
nband = 1
ST_SummaryStats('precip_2011', 'rast', TRUE)
- ST_SummaryStats(rastertable text, rastercolumn text) → record
nband = 1 and exclude_nodata_value = TRUE
ST_SummaryStats('tmin_2009', 'rast')
Variations for ST_ApproxSummaryStats are:
- ST_ApproxSummaryStats(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) → record
ST_ApproxSummaryStats('tmax_2010', 'rast', 1, FALSE, 0.5) ST_ApproxSummaryStats('precip_2011', 'rast', 1, TRUE, 0.2)
- ST_ApproxSummaryStats(rastertable text, rastercolumn text, nband int, sample_percent double precision) → record
exclude_nodata_value = TRUE
ST_ApproxSummaryStats('tmax_2010', 'rast', 1, 0.5) ST_ApproxSummaryStats('precip_2011', 'rast', 1, 0.2)
- ST_ApproxSummaryStats(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) → record
nband = 1
ST_ApproxSummaryStats('tmax_2010', 'rast', FALSE, 0.5) ST_ApproxSummaryStats('precip_2011', 'rast', TRUE, 0.2)
- ST_ApproxSummaryStats(rastertable text, rastercolumn text, sample_percent double precision) → record
nband = 1 and exclude_nodata_value = TRUE
ST_ApproxSummaryStats('tmax_2010', 'rast', 0.5) ST_ApproxSummaryStats('precip_2011', 'rast', 0.2)
- ST_ApproxSummaryStats(rastertable text, rastercolumn text) → record
nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxSummaryStats('tmax_2010', 'rast') ST_ApproxSummaryStats('precip_2011', 'rast')
The mean returned in the coverage functions (has rastertable and rastercolumn arguments) is the true mean of the raster tiles. The standard deviation returned is the standard deviation of all raster tiles.
ST_Count(raster, nband) → bigint
This function calls ST_SummaryStats and only returns the count from that function.
- ST_Count(rast raster, nband int, exclude_nodata_value boolean) → bigint
returns the count as an integer
nband: index of band
exclude_nodata_value: if FALSE, nodata values in band are included in the stats. if TRUE, nodata values are not included
ST_Count(rast, 1, FALSE)
- ST_Count(rast raster, nband int) → bigint
assumes exclude_nodata_value = TRUE
ST_Count(rast, 2)
- ST_Count(rast raster, exclude_nodata_value boolean) → bigint
assumes nband = 1
ST_Count(rast, TRUE)
- ST_Count(rast raster) → bigint
assumes nband = 1 and exclude_nodata_value = TRUE
ST_Count(rast)
The set of ST_ApproxCount functions are:
- ST_ApproxCount(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) → bigint
sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
ST_ApproxCount(rast, 3, FALSE, 0.1) ST_ApproxCount(rast, 1, TRUE, 0.5)
- ST_ApproxCount(rast raster, nband int, sample_percent double precision) → bigint
assumes that nband = 1
ST_ApproxCount(rast, 2 0.01) ST_ApproxCount(rast, 4, 0.025)
- ST_ApproxCount(rast raster, exclude_nodata_value boolean, sample_percent double precision) → bigint
assumes that nband = 1
ST_ApproxCount(rast, FALSE, 0.01) ST_ApproxCount(rast, TRUE, 0.025)
- ST_ApproxCount(rast raster, sample_percent double precision) → bigint
assumes that nband = 1 and exclude_nodata_value = TRUE
ST_ApproxCount(rast, 0.25)
- ST_ApproxCount(rast raster) → bigint
assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxCount(rast)
The following functions are provided for coverage tables.
- ST_Count(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) → bigint
rastertable: name of table with raster column
rastercolumn: name of column of data type raster
ST_Count('tmax_2010', 'rast', 1, FALSE) ST_Count('precip_2011', 'rast', 1, TRUE)
- ST_Count(rastertable text, rastercolumn text, nband int) → bigint
exclude_nodata_value = TRUE
ST_Count('tmax_2010', 'rast', 1)
- ST_Count(rastertable text, rastercolumn text, exclude_nodata_value boolean) → bigint
nband = 1
ST_Count('precip_2011', 'rast', TRUE)
- ST_Count(rastertable text, rastercolumn text) → bigint
nband = 1 and exclude_nodata_value = TRUE
ST_Count('tmin_2009', 'rast')
Variations for ST_ApproxCount are:
- ST_ApproxCount(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) → bigint
ST_ApproxCount('tmax_2010', 'rast', 1, FALSE, 0.5) ST_ApproxCount('precip_2011', 'rast', 1, TRUE, 0.2)
- ST_ApproxCount(rastertable text, rastercolumn text, nband int, sample_percent double precision) → bigint
exclude_nodata_value = TRUE
ST_ApproxCount('tmax_2010', 'rast', 1, 0.5) ST_ApproxCount('precip_2011', 'rast', 1, 0.2)
- ST_ApproxCount(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) → bigint
nband = 1
ST_ApproxCount('tmax_2010', 'rast', FALSE, 0.5) ST_ApproxCount('precip_2011', 'rast', TRUE, 0.2)
- ST_ApproxCount(rastertable text, rastercolumn text, sample_percent double precision) → bigint
nband = 1 and exclude_nodata_value = TRUE
ST_ApproxCount('tmax_2010', 'rast', 0.5) ST_ApproxCount('precip_2011', 'rast', 0.2)
- ST_ApproxCount(rastertable text, rastercolumn text) → bigint
nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxCount('tmax_2010', 'rast') ST_ApproxCount('precip_2011', 'rast')
ST_Sum(raster, nband) → double precision
This function calls ST_SummaryStats and only returns the sum from that function.
- ST_Sum(rast raster, nband int, exclude_nodata_value boolean) → double precision
returns the sum as an integer
nband: index of band
exclude_nodata_value: if FALSE, nodata values in band are included in the stats. if TRUE, nodata values are not included
ST_Sum(rast, 1, FALSE)
- ST_Sum(rast raster, nband int) → double precision
assumes exclude_nodata_value = TRUE
ST_Sum(rast, 2)
- ST_Sum(rast raster, exclude_nodata_value boolean) → double precision
assumes nband = 1
ST_Sum(rast, TRUE)
- ST_Sum(rast raster) → double precision
assumes nband = 1 and exclude_nodata_value = TRUE
ST_Sum(rast)
The set of ST_ApproxSum functions are:
- ST_ApproxSum(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) → double precision
sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
ST_ApproxSum(rast, 3, FALSE, 0.1) ST_ApproxSum(rast, 1, TRUE, 0.5)
- ST_ApproxSum(rast raster, nband int, sample_percent double precision) → double precision
assumes that nband = 1
ST_ApproxSum(rast, 2 0.01) ST_ApproxSum(rast, 4, 0.025)
- ST_ApproxSum(rast raster, exclude_nodata_value boolean, sample_percent double precision) → double precision
assumes that nband = 1
ST_ApproxSum(rast, FALSE, 0.01) ST_ApproxSum(rast, TRUE, 0.025)
- ST_ApproxSum(rast raster, sample_percent double precision) → double precision
assumes that nband = 1 and exclude_nodata_value = TRUE
ST_ApproxSum(rast, 0.25)
- ST_ApproxSum(rast raster) → double precision
assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxSum(rast)
The following functions are provided for coverage tables.
- ST_Sum(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) → double precision
rastertable: name of table with raster column
rastercolumn: name of column of data type raster
ST_Sum('tmax_2010', 'rast', 1, FALSE) ST_Sum('precip_2011', 'rast', 1, TRUE)
- ST_Sum(rastertable text, rastercolumn text, nband int) → double precision
exclude_nodata_value = TRUE
ST_Sum('tmax_2010', 'rast', 1)
- ST_Sum(rastertable text, rastercolumn text, exclude_nodata_value boolean) → double precision
nband = 1
ST_Sum('precip_2011', 'rast', TRUE)
- ST_Sum(rastertable text, rastercolumn text) → double precision
nband = 1 and exclude_nodata_value = TRUE
ST_Sum('tmin_2009', 'rast')
Variations for ST_ApproxSum are:
- ST_ApproxSum(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) → double precision
ST_ApproxSum('tmax_2010', 'rast', 1, FALSE, 0.5) ST_ApproxSum('precip_2011', 'rast', 1, TRUE, 0.2)
- ST_ApproxSum(rastertable text, rastercolumn text, nband int, sample_percent double precision) → double precision
exclude_nodata_value = TRUE
ST_ApproxSum('tmax_2010', 'rast', 1, 0.5) ST_ApproxSum('precip_2011', 'rast', 1, 0.2)
- ST_ApproxSum(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) → double precision
nband = 1
ST_ApproxSum('tmax_2010', 'rast', FALSE, 0.5) ST_ApproxSum('precip_2011', 'rast', TRUE, 0.2)
- ST_ApproxSum(rastertable text, rastercolumn text, sample_percent double precision) → double precision
nband = 1 and exclude_nodata_value = TRUE
ST_ApproxSum('tmax_2010', 'rast', 0.5) ST_ApproxSum('precip_2011', 'rast', 0.2)
- ST_ApproxSum(rastertable text, rastercolumn text) → double precision
nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxSum('tmax_2010', 'rast') ST_ApproxSum('precip_2011', 'rast')
ST_Mean(raster, nband) → double precision
This function calls ST_SummaryStats and only returns the mean from that function.
- ST_Mean(rast raster, nband int, exclude_nodata_value boolean) → double precision
returns the mean as a double precision
nband: index of band
exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
ST_Mean(rast, 1, FALSE)
- ST_Mean(rast raster, nband int) → double precision
assumes exclude_nodata_value = TRUE
ST_Mean(rast, 2)
- ST_Mean(rast raster, exclude_nodata_value boolean) → double precision
assumes nband = 1
ST_Mean(rast, TRUE)
- ST_Mean(rast raster) → double precision
assumes nband = 1 and exclude_nodata_value = TRUE
ST_Mean(rast)
The set of ST_ApproxMean functions are:
- ST_ApproxMean(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) → double precision
sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
ST_ApproxMean(rast, 3, FALSE, 0.1) ST_ApproxMean(rast, 1, TRUE, 0.5)
- ST_ApproxMean(rast raster, nband int, sample_percent double precision) → double precision
assumes that nband = 1
ST_ApproxMean(rast, 2 0.01) ST_ApproxMean(rast, 4, 0.025)
- ST_ApproxMean(rast raster, exclude_nodata_value boolean, sample_percent double precision) → double precision
assumes that nband = 1
ST_ApproxMean(rast, FALSE, 0.01) ST_ApproxMean(rast, TRUE, 0.025)
- ST_ApproxMean(rast raster, sample_percent double precision) → double precision
assumes that nband = 1 and exclude_nodata_value = TRUE
ST_ApproxMean(rast, 0.25)
- ST_ApproxMean(rast raster) → double precision
assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxMean(rast)
The following functions are provided for coverage tables.
- ST_Mean(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) → double precision
rastertable: name of table with raster column
rastercolumn: name of column of data type raster
ST_Mean('tmax_2010', 'rast', 1, FALSE) ST_Mean('precip_2011', 'rast', 1, TRUE)
- ST_Mean(rastertable text, rastercolumn text, nband int) → double precision
exclude_nodata_value = TRUE
ST_Mean('tmax_2010', 'rast', 1)
- ST_Mean(rastertable text, rastercolumn text, exclude_nodata_value boolean) → double precision
nband = 1
ST_Mean('precip_2011', 'rast', TRUE)
- ST_Mean(rastertable text, rastercolumn text) → double precision
nband = 1 and exclude_nodata_value = TRUE
ST_Mean('tmin_2009', 'rast')
Variations for ST_ApproxMean are:
- ST_ApproxMean(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) → double precision
ST_ApproxMean('tmax_2010', 'rast', 1, FALSE, 0.5) ST_ApproxMean('precip_2011', 'rast', 1, TRUE, 0.2)
- ST_ApproxMean(rastertable text, rastercolumn text, nband int, sample_percent double precision) → double precision
exclude_nodata_value = TRUE
ST_ApproxMean('tmax_2010', 'rast', 1, 0.5) ST_ApproxMean('precip_2011', 'rast', 1, 0.2)
- ST_ApproxMean(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) → double precision
nband = 1
ST_ApproxMean('tmax_2010', 'rast', FALSE, 0.5) ST_ApproxMean('precip_2011', 'rast', TRUE, 0.2)
- ST_ApproxMean(rastertable text, rastercolumn text, sample_percent double precision) → double precision
nband = 1 and exclude_nodata_value = TRUE
ST_ApproxMean('tmax_2010', 'rast', 0.5) ST_ApproxMean('precip_2011', 'rast', 0.2)
- ST_ApproxMean(rastertable text, rastercolumn text) → double precision
nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxMean('tmax_2010', 'rast') ST_ApproxMean('precip_2011', 'rast')
The mean returned in the coverage functions (has rastertable and rastercolumn arguments) is the true mean of the raster tiles.
ST_StdDev(raster, nband) → double precision
This function calls ST_SummaryStats and only returns the standard deviation from that function.
- ST_StdDev(rast raster, nband int, exclude_nodata_value boolean) → double precision
returns the standard deviation as a double precision
nband: index of band
exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
ST_StdDev(rast, 1, FALSE)
- ST_StdDev(rast raster, nband int) → double precision
assumes exclude_nodata_value = TRUE
ST_StdDev(rast, 2)
- ST_StdDev(rast raster, exclude_nodata_value boolean) → double precision
assumes nband = 1
ST_StdDev(rast, TRUE)
- ST_StdDev(rast raster) → double precision
assumes nband = 1 and exclude_nodata_value = TRUE
ST_StdDev(rast)
The set of ST_ApproxStdDev functions are:
- ST_ApproxStdDev(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) → double precision
sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
ST_ApproxStdDev(rast, 3, FALSE, 0.1) ST_ApproxStdDev(rast, 1, TRUE, 0.5)
- ST_ApproxStdDev(rast raster, nband int, sample_percent double precision) → double precision
assumes that nband = 1
ST_ApproxStdDev(rast, 2 0.01) ST_ApproxStdDev(rast, 4, 0.025)
- ST_ApproxStdDev(rast raster, exclude_nodata_value boolean, sample_percent double precision) → double precision
assumes that nband = 1
ST_ApproxStdDev(rast, FALSE, 0.01) ST_ApproxStdDev(rast, TRUE, 0.025)
- ST_ApproxStdDev(rast raster, sample_percent double precision) → double precision
assumes that nband = 1 and exclude_nodata_value = TRUE
ST_ApproxStdDev(rast, 0.25)
- ST_ApproxStdDev(rast raster) → double precision
assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxStdDev(rast)
The following functions are provided for coverage tables.
- ST_StdDev(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) → double precision
rastertable: name of table with raster column
rastercolumn: name of column of data type raster
ST_StdDev('tmax_2010', 'rast', 1, FALSE) ST_StdDev('precip_2011', 'rast', 1, TRUE)
- ST_StdDev(rastertable text, rastercolumn text, nband int) → double precision
exclude_nodata_value = TRUE
ST_StdDev('tmax_2010', 'rast', 1)
- ST_StdDev(rastertable text, rastercolumn text, exclude_nodata_value boolean) → double precision
nband = 1
ST_StdDev('precip_2011', 'rast', TRUE)
- ST_StdDev(rastertable text, rastercolumn text) → double precision
nband = 1 and exclude_nodata_value = TRUE
ST_StdDev('tmin_2009', 'rast')
Variations for ST_ApproxStdDev are:
- ST_ApproxStdDev(rastertable text, rastercolumn text, nband int, exclude_nodata_value 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)
- ST_ApproxStdDev(rastertable text, rastercolumn text, nband int, sample_percent double precision) → double precision
exclude_nodata_value = TRUE
ST_ApproxStdDev('tmax_2010', 'rast', 1, 0.5) ST_ApproxStdDev('precip_2011', 'rast', 1, 0.2)
- ST_ApproxStdDev(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) → double precision
nband = 1
ST_ApproxStdDev('tmax_2010', 'rast', FALSE, 0.5) ST_ApproxStdDev('precip_2011', 'rast', TRUE, 0.2)
- ST_ApproxStdDev(rastertable text, rastercolumn text, sample_percent double precision) → double precision
nband = 1 and exclude_nodata_value = TRUE
ST_ApproxStdDev('tmax_2010', 'rast', 0.5) ST_ApproxStdDev('precip_2011', 'rast', 0.2)
- ST_ApproxStdDev(rastertable text, rastercolumn text) → double precision
nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxStdDev('tmax_2010', 'rast') ST_ApproxStdDev('precip_2011', 'rast')
The standard deviation returned in the coverage functions (has rastertable and rastercolumn arguments) is the standard deviation of all raster tiles.
ST_MinMax(raster, nband) → record
This function calls ST_SummaryStats and only returns the min and max values from that function.
- ST_MinMax(rast raster, nband int, exclude_nodata_value boolean) → record
returns the record (min double precision, max double precision)
nband: index of band
exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
ST_MinMax(rast, 1, FALSE)
- ST_MinMax(rast raster, nband int) → record
assumes exclude_nodata_value = TRUE
ST_MinMax(rast, 2)
- ST_MinMax(rast raster, exclude_nodata_value boolean) → record
assumes nband = 1
ST_MinMax(rast, TRUE)
- ST_MinMax(rast raster) → record
assumes nband = 1 and exclude_nodata_value = TRUE
ST_MinMax(rast)
The set of ST_ApproxMinMax functions are:
- ST_ApproxMinMax(rast raster, nband int, exclude_nodata_value boolean, sample_percent record) → record
sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
ST_ApproxMinMax(rast, 3, FALSE, 0.1) ST_ApproxMinMax(rast, 1, TRUE, 0.5)
- ST_ApproxMinMax(rast raster, nband int, sample_percent double precision) → record
assumes that nband = 1
ST_ApproxMinMax(rast, 2 0.01) ST_ApproxMinMax(rast, 4, 0.025)
- ST_ApproxMinMax(rast raster, exclude_nodata_value boolean, sample_percent double precision) → record
assumes that nband = 1
ST_ApproxMinMax(rast, FALSE, 0.01) ST_ApproxMinMax(rast, TRUE, 0.025)
- ST_ApproxMinMax(rast raster, sample_percent double precision) → record
assumes that nband = 1 and exclude_nodata_value = TRUE
ST_ApproxMinMax(rast, 0.25)
- ST_ApproxMinMax(rast raster) → record
assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxMinMax(rast)
The following functions are provided for coverage tables.
- ST_MinMax(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) → record
rastertable: name of table with raster column
rastercolumn: name of column of data type raster
ST_MinMax('tmax_2010', 'rast', 1, FALSE) ST_MinMax('precip_2011', 'rast', 1, TRUE)
- ST_MinMax(rastertable text, rastercolumn text, nband int) → record
exclude_nodata_value = TRUE
ST_MinMax('tmax_2010', 'rast', 1)
- ST_MinMax(rastertable text, rastercolumn text, exclude_nodata_value boolean) → record
nband = 1
ST_MinMax('precip_2011', 'rast', TRUE)
- ST_MinMax(rastertable text, rastercolumn text) → record
nband = 1 and exclude_nodata_value = TRUE
ST_MinMax('tmin_2009', 'rast')
Variations for ST_ApproxMinMax are:
- ST_ApproxMinMax(rastertable text, rastercolumn text, nband int, exclude_nodata_value 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
exclude_nodata_value = TRUE
ST_ApproxMinMax('tmax_2010', 'rast', 1, 0.5) ST_ApproxMinMax('precip_2011', 'rast', 1, 0.2)
- ST_ApproxMinMax(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) → record
nband = 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 = 1 and exclude_nodata_value = TRUE
ST_ApproxMinMax('tmax_2010', 'rast', 0.5) ST_ApproxMinMax('precip_2011', 'rast', 0.2)
- ST_ApproxMinMax(rastertable text, rastercolumn text) → record
nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
ST_ApproxMinMax('tmax_2010', 'rast') ST_ApproxMinMax('precip_2011', 'rast')
ST_Histogram(raster, nband) → set of records
ST_Histogram and ST_ApproxHistogram provide methods to determine a raster's data distribution.
The return of ST_Histogram and ST_ApproxHistogram is a set of records where each record is (min, max, count, percent).
ST_Histogram has the following variations.
- ST_Histogram(rast raster, nband int, exclude_nodata_value boolean, bins int, width double precision[], right boolean) → set of records
returns set of records of four columns (min, max, count, percent)
nband: index of band to process on
exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
bins: the number of categories/bins to have in the histogram. If NULL or value less than one, the number of categories will be auto-computed using Sturges' formula if the number of values ≥ 30 or Square-root choice if number of values < 30.
http://en.wikipedia.org/wiki/Histogram#Mathematical_definition
width: an array indicating the width of each category/bin. If the number of bins is greater than the number of widths, the widths are repeated. Example: 9 bins, widths are [a, b, c] will have the output be [a, b, c, a, b, c, a, b, c].
right: compute the histogram from the right rather than from the left (default). This changes the criteria for evaluating a value x from [a, b) to (a, b].
ST_Histogram(rast, 2, FALSE, NULL, NULL, FALSE) ST_Histogram(rast, 1, TRUE, 100, NULL, FALSE) ST_Histogram(rast, 2, FALSE, NULL, ARRAY[100, 50], FALSE) ST_Histogram(rast, 2, FALSE, 9, ARRAY[1000], TRUE) ST_Histogram(rast, 2, FALSE, 20, ARRAY[100, 200, 300], TRUE)
- ST_Histogram(rast raster, nband int, exclude_nodata_value boolean, bins int, right boolean) → set of records
parameter "width" is not specified thus resulting in all bins having the same widths
ST_Histogram(rast, 2, FALSE, 5, FALSE)
- ST_Histogram(rast raster, nband int, exclude_nodata_value boolean, bins int) → set of records
the parameter "right" is removed and assumed to be FALSE
ST_Histogram(rast, 2, FALSE, 5)
- ST_Histogram(rast raster, nband int, exclude_nodata_value boolean) → set of records
the parameter "bins" is removed and set to NULL. The function will compute the number of bins to use
- ST_Histogram(rast raster, nband int) → set of records
exclude_nodata_value is assumed to be TRUE
- ST_Histogram(rast raster) → set of records
assumes that nband is 1.
- ST_Histogram(rast raster, nband int, bins int, width double precision[], right boolean) → set of records
exclude_nodata_value is assumed to be TRUE
- ST_Histogram(rast raster, nband int, bins int, right boolean) → set of records
all bins will have equal widths
- ST_Histogram(rast raster, nband int, bins int) → set of records
right is assumed to be FALSE
ST_ApproxHistogram should have the following variations.
- ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, width double precision[], right boolean) → set of record
sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider when generating the histogram.
ST_Histogram(rast, 2, FALSE, 0.1, NULL, NULL, FALSE) ST_Histogram(rast, 1, TRUE, 1, 100, NULL, FALSE) ST_Histogram(rast, 2, FALSE, 0.2, NULL, ARRAY[100, 50], FALSE) ST_Histogram(rast, 2, FALSE, 0.25, 9, ARRAY[1000], TRUE) ST_Histogram(rast, 2, FALSE, 0.05, 20, ARRAY[100, 200, 300], TRUE)
- ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, right boolean) → set of records
parameter "width" is not specified thus resulting in all bins having the same widths
- ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int) → set of records
the parameter "right" is removed and assumed to be FALSE
ST_ApproxHistogram(rast, 2, FALSE, 5)
- ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) → set of records
the parameter "bins" is removed and set to NULL so that function can compute the number of bins to use
- ST_ApproxHistogram(rast raster, nband int, sample_percent double precision) → set of records
exclude_nodata_value is assumed to be TRUE
- ST_ApproxHistogram(rast raster, nband int) → set of records
assumes that sample_percent is 0.1
- ST_ApproxHistogram(rast raster, sample_percent double_precision) → set of records
assumes that nband is 1
- ST_ApproxHistogram(rast raster) → set of records
assumes that nband is 1 and sample_percent is 0.1
- ST_ApproxHistogram(rast raster, nband int, sample_percent double precision, bins int, width double precision[], right boolean) → set of records
exclude_nodata_value is assumed to be TRUE
- ST_ApproxHistogram(rast raster, nband int, sample_percent double precision, bins int, right boolean) → set of records
all bins will have equal widths
- ST_ApproxHistogram(rast raster, nband int, sample_percent double precision, bins int) → set of records
right is assumed to be FALSE
The following set of function are for coverages.
- ST_Histogram(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, bins int default 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) → set of records
rastertable: name of table with raster column
rastercolumn: name of column of data type raster
ST_Histogram('tmax_2010', 'rast') ST_Histogram('precip_2011', 'rast', 1) ST_Histogram('precip_2011', 'rast', 1, FALSE) ST_Histogram('precip_2011', 'rast', 1, FALSE, 5) ST_Histogram('precip_2011', 'rast', 1, FALSE, 10, NULL) ST_Histogram('precip_2011', 'rast', 1, FALSE, 10, NULL, TRUE)
- ST_Histogram(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, bins int, right boolean) → set of records
ST_Histogram('tmin_2010', 'rast', 2, FALSE, 5, FALSE)
- ST_Histogram(rastertable text, rastercolumn text, nband int, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) → set of records
ST_Histogram('ndvi_2010', 'rast', 1, 5) ST_Histogram('ndvi_2010', 'rast', 1, 0, ARRAY[0.5]::double precision[]) ST_Histogram('ndvi_2010', 'rast', 1, 5, NULL, TRUE)
- ST_Histogram(rastertable text, rastercolumn text, nband int, bins int, right boolean) → set of records
ST_Histogram('veg_2009', 'rast', 2, 3, FALSE) ST_Histogram('veg_2009', 'rast', 2, 3, TRUE)
A set of functions of ST_ApproxHistogram for coverage tables:
- ST_ApproxHistogram(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1, bins int DEFAULT 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) → set of records
ST_ApproxHistogram('precip_2010', 'rast') ST_ApproxHistogram('precip_2010', 'rast', 1) ST_ApproxHistogram('precip_2010', 'rast', 2, FALSE) ST_ApproxHistogram('precip_2010', 'rast', 1, TRUE, 0.25) ST_ApproxHistogram('precip_2010', 'rast', 3, FALSE, 0.2, 10) ST_ApproxHistogram('precip_2010', 'rast', 1, TRUE, 0.1, 0, ARRAY[1]::double precision[]) ST_ApproxHistogram('precip_2010', 'rast', 1, TRUE, 0.1, 0, ARRAY[1]::double precision[], FALSE)
- ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, right boolean)
- ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision)
- ST_ApproxHistogram(rastertable text, rastercolumn text, sample_percent double precision)
- ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE)
- ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision, bins int, right boolean)
ST_Quantile(raster, nband) → set of records
In addition to determining the histogram of a raster, providing the ability to compute quantiles permits a user to reference a value in the context of the sample or population. Thus, a value could be examined to be at the raster's 25%, 50%, 75% percentile.
http://en.wikipedia.org/wiki/Quantile
ST_Quantile variations:
- ST_Quantile(rast raster, nband int, exclude_nodata_value boolean, quantiles double precision[]) → set of records
each row returned is of (quantile double precision, value double precision)
nband: index of band to process on
exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
quantiles: array of percentages to compute values for
ST_Quantile(rast, 1, FALSE, ARRAY[0.1, 0.3, 0.7]) ST_Quantile(rast, 1, TRUE, ARRAY[0.2]) ST_Quantile(rast, 1, FALSE, ARRAY[0, 1])
- ST_Quantile(rast raster, nband int, quantiles double precision[]) → set of records
"exclude_nodata_value" is assumed to be TRUE
ST_Quantile(rast, 1, ARRAY[0.1, 0.3, 0.7])
- ST_Quantile(rast raster, nband int, exclude_nodata_value boolean) → set of records
"quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
- ST_Quantile(rast raster, nband int) → set of records
"exclude_nodata_value" is assumed to be TRUE and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
- ST_Quantile(rast raster, quantiles double precision[]) → set of records
"nband" is assumed to be 1 and "exclude_nodata_value" is TRUE
- ST_Quantile(rast raster) → set of records
"nband" is assumed to be 1 and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
- ST_Quantile(rast raster, nband int, exclude_nodata_value boolean, quantile double precision) → record
quantile: the single percentile to compute
- ST_Quantile(rast raster, nband int, quantile double precision) → record
"exclude_nodata_value" is assumed to be TRUE
- ST_Quantile(rast raster, exclude_nodata_value boolean, quantile double precision) → record
"nband" is assumed to be 1
- ST_Quantile(rast raster, quantile double precision) → record
"nband" is assumed to be 1 and "exclude_nodata_value" is assumed to be TRUE
ST_ApproxQuantile adds a "sample_percent" indicating the percentage of the raster to sample
- ST_ApproxQuantile(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, quantiles double precision[]) → set of records
nband: index of band to process on
exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider when computing the quantiles
quantiles: array of percentages to compute values for
ST_ApproxQuantile(rast, 1, FALSE, 0.1, ARRAY[0.1, 0.3, 0.7]) ST_ApproxQuantile(rast, 1, TRUE, .2, ARRAY[0.2]) ST_ApproxQuantile(rast, 1, FALSE, 0.3, ARRAY[0, 1])
- ST_ApproxQuantile(rast raster, nband int, sample_percent double precision, quantiles double precision[]) → set of records
"exclude_nodata_value" is assumed to be TRUE
ST_ApproxQuantile(rast, 1, .05, ARRAY[0.1, 0.3, 0.7])
- ST_ApproxQuantile(rast raster, nband int, sample_percent double precision) → set of records
"exclude_nodata_value" is assumed to be TRUE and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
- ST_ApproxQuantile(rast raster, sample_percent double precision, quantiles double precision[]) → set of records
"nband" is assumed to be 1
- ST_ApproxQuantile(rast raster, nband int, sample_percent double precision, quantile double precision) → record
quantile: the single percentile to compute
- ST_ApproxQuantile(rast raster, sample_percent double precision, quantile double precision) → record
"nband" is assumed to be 2
- ST_ApproxQuantile(rast raster, sample_percent double precision) → set of records
"nband" is assumed to be 1 and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
- ST_ApproxQuantile(rast raster, nband int, quantile double precision) → record
"sample_percent" assumed to be 0.1
- ST_ApproxQuantile(rast raster, quantiles double precision[]) → set of records
"nband" is assumed to be 1 and "sample_percent" assumed to be 0.1
- ST_ApproxQuantile(rast raster, quantile double precision) → record
"nband" assumed to be 1 and "sample_percent" assumed to be 0.1
- ST_ApproxQuantile(rast raster, nband int) → set of records
"quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1] and "sample_percent" assumed to be 0.1
- ST_ApproxQuantile(rast raster) → set of records
"nband" is assumed to be 1, "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1] and "sample_percent" assumed to be 0.1
Objective FV.05 - Being able to reproject a raster. - Done
ST_Transform(raster|geometry, SRID) → same type as input
Objective FV.06 - Being able to do some base raster operations. - Done Partially
ST_ValueCount(raster, value) → integer
ST_ValueCount provides the ability to count the number of times that a user-provided value is present in a raster. To handle floating point values, a rounding argument is provided.
A set of functions for one or more search values:
If NULL is passed for "searchvalues" to any of the ST_ValueCount variations with "searchvalues", the function returns the counts for all unique values
- ST_ValueCount(rast raster, nband integer, exclude_nodata_value boolean, searchvalues double precision[], roundto double precision) → setof record (searchvalue, count)
returns the number of times that each value in searchvalues is present in the raster
exclude_nodata_value: if FALSE, nodata values in band are considered in the count. if TRUE, nodata values are not considered
searchvalues: the set of values to count in the raster
roundto: the decimal position to round a pixel value to. Originally intended for use with 32BF and 64BF pixel types, it can also be used with integers when round to the tens, hundreds or higher place.
examples are…
roundto < 0: no rounding 0: no rounding 0.1: round to the tenths place 0.01: round to the hundredths place 0.001: round to the thousandths place 1: round to the ones place 10: round to the tens place 100: round to the hundreds place
ST_ValueCount(rast, 1, TRUE, ARRAY[23], 0) ST_ValueCount(rast, 5, FALSE, ARRAY[3.14], 0.01) ST_ValueCount(rast, 2, TRUE, ARRAY[100], 100) ST_ValueCount(rast, 1, FALSE, ARRAY[-9999, 0], 1) ST_ValueCount(rast, 1, FALSE, NULL::double precision[], 1)
- ST_ValueCount(rast raster, nband integer, searchvalues double precision[], roundto double precision) → setof record (searchvalue, count)
exclude_nodata_value is assumed to be TRUE
ST_ValueCount(rast, 5, ARRAY[3.14], 0.01) ST_ValueCount(rast, 2, NULL::double precision[], 100)
- ST_ValueCount(rast raster, nband integer, searchvalues double precision[]) → setof record (searchvalue, count)
roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE
ST_ValueCount(rast, 1, ARRAY[-9999]) ST_ValueCount(rast, 1, NULL::double precision[])
- ST_ValueCount(rast raster, searchvalues double precision[], roundto double precision) → setof record (searchvalue, count)
nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE.
- ST_ValueCount(rast raster, searchvalues double precision[]) → setof record (searchvalue, count)
nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE.
A set of functions for a single search value:
- ST_ValueCount(rast raster, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision) → integer
returns the number of times that searchvalue is present in the raster
searchvalue: the value to count in the raster
ST_ValueCount(rast, 1, TRUE, 23, 0) ST_ValueCount(rast, 5, FALSE, 3.14, 0.01) ST_ValueCount(rast, 2, TRUE, 100, 100) ST_ValueCount(rast, 1, FALSE, -9999, 1)
- ST_ValueCount(rast raster, nband integer, searchvalue double precision, roundto double precision) → integer
exclude_nodata_value is assumed to be TRUE
ST_ValueCount(rast, 5, 3.14, 0.01) ST_ValueCount(rast, 2, 100, 100)
- ST_ValueCount(rast raster, nband integer, searchvalue double precision) → integer
roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE
ST_ValueCount(rast, 1, -9999)
- ST_ValueCount(rast raster, searchvalue double precision, roundto double precision) → integer
nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE.
- ST_ValueCount(rast raster, searchvalue double precision) → integer
nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE.
The set of functions for processing coverages return "bigint" instead of "integer".
A set of functions for one or more search values:
- ST_ValueCount(rastertable text, rastercolumn text, nband integer, exclude_nodata_value boolean, searchvalues double precision[], roundto double precision) → setof record (searchvalue, count)
rastertable: name of the table with a raster column
rastercolumn: name of the raster column
ST_ValueCount('test', 'rast', 1, TRUE, ARRAY[23], 0) ST_ValueCount('test', 'rast', 5, FALSE, ARRAY[3.14], 0.01) ST_ValueCount('test', 'rast', 2, TRUE, ARRAY[100], 100) ST_ValueCount('test', 'rast', 1, FALSE, ARRAY[-9999, 0], 1) ST_ValueCount('test', 'rast', 1, FALSE, NULL::double precision[], 1)
- ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalues double precision[], roundto double precision) → setof record (searchvalue, count)
exclude_nodata_value is assumed to be TRUE
ST_ValueCount('test', 'rast', 5, ARRAY[3.14], 0.01) ST_ValueCount('test', 'rast', 2, NULL::double precision[], 100)
- ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalues double precision[]) → setof record (searchvalue, count)
roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE
ST_ValueCount('test', 'rast', 1, ARRAY[-9999]) ST_ValueCount('test', 'rast', 1, NULL::double precision[])
- ST_ValueCount(rastertable text, rastercolumn text, searchvalues double precision[], roundto double precision) → setof record (searchvalue, count)
nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE.
- ST_ValueCount(rastertable text, rastercolumn text, searchvalues double precision[]) → setof record (searchvalue, count)
nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE.
A set of functions for a single search value:
- ST_ValueCount(rastertable text, rastercolumn text, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision) → bigint
searchvalue: the value to count in the raster
ST_ValueCount('test', 'rast', 1, TRUE, 23, 0) ST_ValueCount('test', 'rast', 5, FALSE, 3.14, 0.01) ST_ValueCount('test', 'rast', 2, TRUE, 100, 100) ST_ValueCount('test', 'rast', 1, FALSE, -9999, 1)
- ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalue double precision, roundto double precision) → bigint
exclude_nodata_value is assumed to be TRUE
ST_ValueCount('test', 'rast', 5, 3.14, 0.01) ST_ValueCount('test', 'rast', 2, 100, 100)
- ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalue double precision) → bigint
roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE
ST_ValueCount('test', 'rast', 1, -9999)
- ST_ValueCount(rastertable text, rastercolumn text, searchvalue double precision, roundto double precision) → bigint
nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE.
- ST_ValueCount(rastertable text, rastercolumn text, searchvalue double precision) → bigint
nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE.
ST_ValuePercent(raster, value) → double precision
ST_ValuePercent is the sibling of ST_ValueCount and returns the percentage of a raster's band that is of a specified value. To handle floating point values, a rounding argument is provided.
A set of functions for one or more search values:
If NULL is passed for "searchvalues" to any of the ST_ValuePercent variations with "searchvalues", the function returns the percents for all unique values
- ST_ValuePercent(rast raster, nband integer, exclude_nodata_value boolean, searchvalues double precision[], roundto double precision) → setof record (searchvalue, percent)
returns the percentage of a raster's band that each value in searchvalues is found
exclude_nodata_value: if FALSE, nodata values in band are considered in the percents. if TRUE, nodata values are not considered
searchvalues: the set of values to get percents for in the raster
roundto: the decimal position to round a pixel value to. Originally intended for use with 32BF and 64BF pixel types, it can also be used with integers when round to the tens, hundreds or higher place.
examples are…
roundto < 0: no rounding 0: no rounding 0.1: round to the tenths place 0.01: round to the hundredths place 0.001: round to the thousandths place 1: round to the ones place 10: round to the tens place 100: round to the hundreds place
ST_ValuePercent(rast, 1, TRUE, ARRAY[23], 0) ST_ValuePercent(rast, 5, FALSE, ARRAY[3.14], 0.01) ST_ValuePercent(rast, 2, TRUE, ARRAY[100], 100) ST_ValuePercent(rast, 1, FALSE, ARRAY[-9999, 0], 1) ST_ValuePercent(rast, 1, FALSE, NULL::double precision[], 1)
- ST_ValuePercent(rast raster, nband integer, searchvalues double precision[], roundto double precision) → setof record (searchvalue, percent)
exclude_nodata_value is assumed to be TRUE
ST_ValuePercent(rast, 5, ARRAY[3.14], 0.01) ST_ValuePercent(rast, 2, NULL::double precision[], 100)
- ST_ValuePercent(rast raster, nband integer, searchvalues double precision[]) → setof record (searchvalue, percent)
roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE
ST_ValuePercent(rast, 1, ARRAY[-9999]) ST_ValuePercent(rast, 1, NULL::double precision[])
- ST_ValuePercent(rast raster, searchvalues double precision[], roundto double precision) → setof record (searchvalue, percent)
nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE.
- ST_ValuePercent(rast raster, searchvalues double precision[]) → setof record (searchvalue, percent)
nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE.
A set of functions for a single search value:
- ST_ValuePercent(rast raster, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision) → integer
searchvalue: the value to get a percent for in the raster
ST_ValuePercent(rast, 1, TRUE, 23, 0) ST_ValuePercent(rast, 5, FALSE, 3.14, 0.01) ST_ValuePercent(rast, 2, TRUE, 100, 100) ST_ValuePercent(rast, 1, FALSE, -9999, 1)
- ST_ValuePercent(rast raster, nband integer, searchvalue double precision, roundto double precision) → integer
exclude_nodata_value is assumed to be TRUE
ST_ValuePercent(rast, 5, 3.14, 0.01) ST_ValuePercent(rast, 2, 100, 100)
- ST_ValuePercent(rast raster, nband integer, searchvalue double precision) → integer
roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE
ST_ValuePercent(rast, 1, -9999)
- ST_ValuePercent(rast raster, searchvalue double precision, roundto double precision) → integer
nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE.
- ST_ValuePercent(rast raster, searchvalue double precision) → integer
nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE.
The set of functions for processing coverages return "bigint" instead of "integer".
A set of functions for one or more search values:
- ST_ValuePercent(rastertable text, rastercolumn text, nband integer, exclude_nodata_value boolean, searchvalues double precision[], roundto double precision) → setof record (searchvalue, percent)
rastertable: name of the table with a raster column
rastercolumn: name of the raster column
ST_ValuePercent('test', 'rast', 1, TRUE, ARRAY[23], 0) ST_ValuePercent('test', 'rast', 5, FALSE, ARRAY[3.14], 0.01) ST_ValuePercent('test', 'rast', 2, TRUE, ARRAY[100], 100) ST_ValuePercent('test', 'rast', 1, FALSE, ARRAY[-9999, 0], 1) ST_ValuePercent('test', 'rast', 1, FALSE, NULL::double precision[], 1)
- ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalues double precision[], roundto double precision) → setof record (searchvalue, percent)
exclude_nodata_value is assumed to be TRUE
ST_ValuePercent('test', 'rast', 5, ARRAY[3.14], 0.01) ST_ValuePercent('test', 'rast', 2, NULL::double precision[], 100)
- ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalues double precision[]) → setof record (searchvalue, percent)
roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE
ST_ValuePercent('test', 'rast', 1, ARRAY[-9999]) ST_ValuePercent('test', 'rast', 1, NULL::double precision[])
- ST_ValuePercent(rastertable text, rastercolumn text, searchvalues double precision[], roundto double precision) → setof record (searchvalue, percent)
nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE.
- ST_ValuePercent(rastertable text, rastercolumn text, searchvalues double precision[]) → setof record (searchvalue, percent)
nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE.
A set of functions for a single search value:
- ST_ValuePercent(rastertable text, rastercolumn text, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision) → bigint
searchvalue: the value to get a percent for in the raster
ST_ValuePercent('test', 'rast', 1, TRUE, 23, 0) ST_ValuePercent('test', 'rast', 5, FALSE, 3.14, 0.01) ST_ValuePercent('test', 'rast', 2, TRUE, 100, 100) ST_ValuePercent('test', 'rast', 1, FALSE, -9999, 1)
- ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalue double precision, roundto double precision) → bigint
exclude_nodata_value is assumed to be TRUE
ST_ValuePercent('test', 'rast', 5, 3.14, 0.01) ST_ValuePercent('test', 'rast', 2, 100, 100)
- ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalue double precision) → bigint
roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE
ST_ValuePercent('test', 'rast', 1, -9999)
- ST_ValuePercent(rastertable text, rastercolumn text, searchvalue double precision, roundto double precision) → bigint
nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE.
- ST_ValuePercent(rastertable text, rastercolumn text, searchvalue double precision) → bigint
nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE.