wiki:WKTRaster/SpecificationWorking02

Version 26 (modified by pracine, 14 years ago) ( diff )

--

PostGIS WKT Raster Beta 0.2.4 Working Specifications


Objective B02x - Implement better support for NULL, Empty, HasNoBand(rast), HasNoBand(rast, band) and BandIsNoData rasters in all functions.

Each function should better handle NULL rasters, empty rasterm rasters with no band and bands only filled with nodata values.

1) Generally, when NULL rasters are provided, return NULL. If the function involves a second non NULL raster and something can be done with it, do it.

2) Generally, when empty rasters are provided (ST_IsEmpty, width=0 or height=0), return an empty raster. If the function involves a second non empty raster and something can be done with it, do it.

2) Generally, when a HasNoBand(rast) or a HasNoBand(rast, band) raster is provided return a raster with no band but with the right extent. If the function involves a second raster having a band or the band, treat the first missing band like a BandIsNoData.

4) A BandIsNoData raster is a normal raster but many functions can be optimized with this type of raster.

5) All functions having missing the requested information (about its extent when it is a NULL or an empty raster or about its band when it is a HasNoBand(rast) or a HasNoBand(rast, band) raster) should return NULL or a documented value.

6) Try as less as possible to return EXCEPTION (or ERROR).

ST_IsEmpty(rast) -> boolean

Returns TRUE if the raster width or the raster height is 0.

ST_HasNoBand

Variants

1) ST_HasNoBand(rast, band) -> boolean

2) ST_HasNoBand(rast) -> boolean

Returns TRUE if the the raster does not have this band.

Variant 2 returns TRUE if the the raster does not have any band.

ST_BandIsNoData

Variants

1) ST_BandIsNoData(rast, band) -> boolean

2) ST_BandIsNoData(rast) -> boolean

Returns TRUE if the specified raster band is only filled with no data value.

Variant 2 default to band 1.

Implementation details

This require a new flag to be set in the core at import and at edition.


Objective B02x - Being able to clip a raster.

ST_Clip

Returns the subset of a raster as a raster.

All metadata are copied from the source raster (except ulx, uly, width and height which must be computed).

Variants

1) ST_Clip(raster, ulx, uly, lrx, lry) -> raster

2) ST_Clip(raster, geometry) -> raster

3) ST_Clip(raster, geometry, 'EXACT') -> raster

Variant 1) takes the upper left and lower left corner of the desired zone. Variant 2) determine the extent of this zone from the extent of a geometry. Variant 3) determine the extent of this zone from the extent of a geometry and set all pixel outside the geometry to no data values.

If the geometry is totally included into one pixel (a point for example), only this pixel is kept in the returned raster.

Implementation details

Implemented as a wrapper around ST_MapAlgebra.

newrast := ST_AddBand(ST_MakeEmptyRaster(x2 - x1, y2 - y1, ST_Raster2WorldCoordX(rast, x1, y2), ST_Raster2WorldCoordY(rast, x1, y2), ST_PixelSizeX(rast), ST_PixelSizeY(rast),ST_SkewX(rast),ST_SkewY(rast), ST_SRID(rast)), ‘1BB’, 1, 0) newrast := ST_MultiBandMapAlgebra(rast, newrast, ‘r1’, ‘INTERSECTION’)

Could also be implemented as ST_Intersection -> ST_Band(ST_Intersection(geometry, raster, band, “TRIM”), 1) Would require some kind of TRIM and would be slower.

This function is necessary to optimize ST_Intersection. The raster to be polygonised before proceeding to a vector intersection should first be clipped to the minimal intersecting area using ST_Clip().


Objective B02x - 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

Return 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 B02x - 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 B02x - Being able to set and get the skew of a raster in terms of rotation.

ST_SetRotation(raster, angle)

Set the rotation of the raster. This method actually derive values for pixelsizex, pixelsizey, skewx and skewy based on the provided rotation angle.

Open Question:

PR: The angle should be provided in radian or in degree?

ST_Rotation(raster) -> float64

Return the georeference's rotation angle in (degree or radiant?) derived from the pixel size and the skew.

PR: I think getting the rotation get no sence since the result of pixelsizes and skew is not necessarily a rotation. It make sence to set it though.

Attachments (2)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.