ST_DWithin — Return true if rasters rastA and rastB are within the specified distance of each other.
boolean ST_DWithin(
                        raster 
                        rastA
                    , 
                        integer 
                        nbandA
                    , 
                        raster 
                        rastB
                    , 
                        integer 
                        nbandB
                    , 
                        double precision 
                        distance_of_srid
                    );
boolean ST_DWithin(
                        raster 
                        rastA
                    , 
                        raster 
                        rastB
                    , 
                        double precision 
                        distance_of_srid
                    );
Return true if rasters rastA and rastB are within the specified distance of each other. 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.
The distance is specified in units defined by the spatial reference system of the rasters. For this function to make sense, the source rasters must both be of the same coordinate projection, having the same SRID.
![]()  | |
This operand 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_DWithin(ST_Polygon(raster), geometry).  | 
Availability: 2.1.0