wiki:WKTRaster/SpecificationWorking03

Version 5 (modified by dzwarg, 14 years ago) ( diff )

Fleshed out ST_MapAlgebra specs

PostGIS WKT Raster Beta 03 (and up) Working Specifications

Quick Links


Objective B03a - Being able to set all the properties of a raster.

ST_SetSRID(raster|geometry, integer)
ST_SetPixelType(raster, band, string)
ST_SetPixelSize(raster)
ST_SetNoDataValue(raster, band, value)
ST_SetGeoReference(raster, string)


Objective B03b - Being able to reproject a raster.

ST_Transform(raster|geometry, SRID) → same type as input


Objective B03c - Being able to do some base raster operations.

ST_Area(raster|geometry) → double
ST_Count(raster, value) → integer

ST_Resample(raster, pixelsize, method) → raster

Recompute a raster in order to change its pixel size and/or the position of its upper left corner.

ST_SelectByValue(raster|geometry, ‘expression’) → same type as first argument
ST_Reclass(raster|geometry,string) → same type as first argument

ST_MapAlgebra(raster|geometry, [raster|geometry,…] ‘mathematical expression’, ‘raster’ |’geometry’) → raster/geometry

Variant 1: ST_MapAlgebra(raster|geometry, [raster|geometry,…] ‘mathematical expression’, ‘raster’ |’geometry’, originx, originy, pixelsizex, pixelsizey, rotation ) → raster/geometry

Variant 2: ST_MapAlgebra(raster|geometry, [raster|geometry,…] 'mathematical expression', 'raster' |'geometry', integer) →raster/geometry

Variant 3: ST_MapAlgebra(raster|geometry, [raster|geometry,…] 'mathematical expression', 'raster' |'geometry', raster) →raster/geometry

The first raster passed to ST_MapAlgebra is the 'master' raster, unless either:

1 additional parameter specifies the index (in the parameter list) of the 'master' raster.
1 additional parameter specifies a raster whose origin and cell size should be used to compute the output raster.
4 additional parameters are passed specifying the origin, cell size, and raster rotation.

This function implicitly calls ST_Intersects(raster|geometry, [raster|geometry,…]) to detect if the rasters are overlapping before performing any computation. Additionally, the resulting raster will have the same extent as the result of ST_Intersection(raster, integer, geometry).

One of the implications of the ST_Intersects inclusion is that:

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

Open Question: Should ST_MapAlgebra resample rasters internally, or produce a raster that can be processed by ST_Resample? If so, variant 1 and variant 3 can be removed, and all ST_MapAlgebra results can be processed through ST_Resample, like:

ST_Resample(ST_MapAlgebra(raster, [raster,…] 'mathematical expression', integer), originx, originy, pixelsizex, pixelsizey)
ST_Resample(ST_MapAlgebra(raster, [raster,…] 'mathematical expression', integer), rastergrid)

ST_Clip(raster|geometry,geometry) → same type as first argument
ST_Flip(raster|geometry, ’vertical’|’horizontal’) → same type as first argument


Objective B03d - Being able to quickly get raster statistics.

Add cached basic raster statistic to the base raster WKB format.


Objective B03e - 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.


PostGIS WKT Raster Beta 0.4


Objective B04a - Being able to convert a raster to standards formats.

ST_AsKML(raster|geometry) → string
ST_AsSVG(raster|geometry) → string


Objective B04b - Being able to control the validity of a raster.

ST_IsEmpty(raster|geometry) → boolean
ST_mem_size(raster|geometry) → integer
ST_isvalid(raster|geometry) → boolean


Objective B04c - 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)


PostGIS WKT Raster Beta 0.5


Objective B05a - Being able to derive a raster layer from vector layer.

ST_Interpolate(points, pixelsize, method) → raster


Objective B05b - 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_ConvexHull(raster|geometry) → same type as input
ST_Difference(raster|geometry A, raster|geometry B) → same type as first argument
ST_SymDifference(raster|geometry,raster|geometry,‘raster’|’geometry’) → raster/geometry


PostGIS WKT Raster Beta 0.6


Objective B06a - 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 B07b - Being able to edit a raster

ST_Value(raster, band, x, y) → value
Return value of a single pixel. Pixel location is specified by 1-based index of Nth band of raster and X,Y coordinates.
The X coordinate is expected to be in range of [1, ST_Width(raster)] and Y coordinate in range of [1, ST_Height(raster))]. Return value is of type of 64-bit float-point number.
TODO: mloskot: Should we return NUMERIC instead of FLOAT8?

ST_SetValue(raster, band, x, y, value)
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

Other functions

ST_AsBinary(raster, compression)
ST_RasterFromWKB(raster, [<srid>])
ST_RasterFromText(string, [<srid>])
ST_AsText(raster)


Note: See TracWiki for help on using the wiki.