## Name

ST_Intersection — 返回一个栅格或一组几何像素值对，表示两个栅格的共享部分或栅格矢量化和几何图形的几何交集。

## Synopsis

setof geomval ST_Intersection(geometry geom, raster rast, integer band_num=1);

setof geomval ST_Intersection(raster rast, geometry geom);

setof geomval ST_Intersection(raster rast, integer band, geometry geomin);

raster ST_Intersection(raster rast1, raster rast2, double precision[] nodataval);

raster ST_Intersection(raster rast1, raster rast2, text returnband, double precision[] nodataval);

raster ST_Intersection(raster rast1, integer band1, raster rast2, integer band2, double precision[] nodataval);

raster ST_Intersection(raster rast1, integer band1, raster rast2, integer band2, text returnband, double precision[] nodataval);

## 描述

 要更好地控制结果范围或遇到无数据值时返回的内容，请使用 ST_MapAlgebraExpr的两个栅格版本。
 要计算栅格波段与栅格空间中几何图形的交集，请使用 ST_Clip。 ST_Clip 适用于多波段栅格，并且不返回与栅格化几何对应的波段。
 ST_Intersection 应与 ST_Intersects 以及栅格列和/或几何列上的索引结合使用。

## 示例：几何、光栅——产生几何值

SELECT
foo.rid,
foo.gid,
ST_AsText((foo.geomval).geom) As geomwkt,
(foo.geomval).val
FROM (
SELECT
A.rid,
g.gid,
ST_Intersection(A.rast, g.geom) As geomval
FROM dummy_rast AS A
CROSS JOIN (
VALUES
(1, ST_Point(3427928, 5793243.85) ),
(2, ST_GeomFromText('LINESTRING(3427927.85 5793243.75,3427927.8 5793243.75,3427927.8 5793243.8)')),
(3, ST_GeomFromText('LINESTRING(1 2, 3 4)'))
) As g(gid,geom)
WHERE A.rid = 2
) As foo;

rid | gid |      geomwkt                                               | val
-----+-----+---------------------------------------------------------------------------------------------
2 |   1 | POINT(3427928 5793243.85)                                  | 249
2 |   1 | POINT(3427928 5793243.85)                                  | 253
2 |   2 | POINT(3427927.85 5793243.75)                               | 254
2 |   2 | POINT(3427927.8 5793243.8)                                 | 251
2 |   2 | POINT(3427927.8 5793243.8)                                 | 253
2 |   2 | LINESTRING(3427927.8 5793243.75,3427927.8 5793243.8)   | 252
2 |   2 | MULTILINESTRING((3427927.8 5793243.8,3427927.8 5793243.75),...) | 250
2 |   3 | GEOMETRYCOLLECTION EMPTY