ST_Contains
Name
ST_Contains — Return true if no points of raster rastB lie in the exterior of raster rastA and at least one point of the interior of rastB lies in the interior of rastA.
Synopsis
boolean
ST_Contains
(
raster
rastA
,
integer
nbandA
,
raster
rastB
,
integer
nbandB
)
;
boolean
ST_Contains
(
raster
rastA
,
raster
rastB
)
;
Description
Raster rastA contains rastB if and only if no points of rastB lie in the exterior of rastA and at least one point of the interior of rastB lies in the interior of rastA. If the band number is not provided (or set to NULL), only the convex hull of the raster is considered in the test. If the band number is provided, only those pixels with value (not NODATA) are considered in the test.
This function will make use of any indexes that may be available on the rasters. |
To test the spatial relationship of a raster and a geometry, use ST_Polygon on the raster, e.g. ST_Contains(ST_Polygon(raster), geometry) or ST_Contains(geometry, ST_Polygon(raster)). |
ST_Contains() is the inverse of ST_Within(). So, ST_Contains(rastA, rastB) implies ST_Within(rastB, rastA). |
Availability: 2.1.0
Examples
-- specified band numbers SELECT r1.rid, r2.rid, ST_Contains(r1.rast, 1, r2.rast, 1) FROM dummy_rast r1 CROSS JOIN dummy_rast r2 WHERE r1.rid = 1; NOTICE: The first raster provided has no bands rid | rid | st_contains -----+-----+------------- 1 | 1 | 1 | 2 | f
-- no band numbers specified SELECT r1.rid, r2.rid, ST_Contains(r1.rast, r2.rast) FROM dummy_rast r1 CROSS JOIN dummy_rast r2 WHERE r1.rid = 1; rid | rid | st_contains -----+-----+------------- 1 | 1 | t 1 | 2 | f