RS_Intersects¶
Introduction: Returns true if raster or geometry on the left side intersects with the raster or geometry on the right side. The convex hull of the raster is considered in the test.
Rules for testing spatial relationship:
- If the raster or geometry does not have a defined SRID, it is assumed to be in WGS84.
- If both sides are in the same CRS, then perform the relationship test directly.
- A raster and a point or a multipoint in different CRSs are compared in the CRS of the raster, where the sides of the raster are straight. The point is transformed into that CRS. Each point of a multipoint is compared on its own. A point that is on a side of the raster as nearly as the transformation is exact is on that side: the raster intersects it and does not contain it.
- Otherwise, both sides will be transformed to WGS84 before the relationship test. That is the rule for a raster and a line or a polygon, for two rasters, and for a raster and a point that the CRS of the raster has no coordinates for. A projection has coordinates for a part of the globe only: a UTM zone for the longitudes around its central meridian, a Mercator projection for everything but the poles.
Before v2.0.0, a raster and a point in different CRSs were both transformed to WGS84. A raster was the quadrilateral through its four corners there, which is not its shape when its CRS is far from longitude and latitude: every point inside a raster around a pole was reported as outside it.
Format:
RS_Intersects(raster: Raster, geom: Geometry)
RS_Intersects(geom: Geometry, raster: Raster)
RS_Intersects(raster0: Raster, raster1: Raster)
Return type: Boolean
Since: v1.5.0
SQL Example
SELECT RS_Intersects(RS_MakeEmptyRaster(1, 20, 20, 2, 22, 1), ST_SetSRID(ST_PolygonFromEnvelope(0, 0, 10, 10), 4326)) rast_geom,
RS_Intersects(RS_MakeEmptyRaster(1, 20, 20, 2, 22, 1), RS_MakeEmptyRaster(1, 10, 10, 1, 11, 1)) rast_rast
Output:
+---------+---------+
|rast_geom|rast_rast|
+---------+---------+
| true| true|
+---------+---------+