Name

ST_SetM — 返回与输入几何图形具有相同X/Y坐标的几何图形,并使用请求的重采样算法将栅格中的值复制到Z维度。

Synopsis

geometry ST_SetM(raster rast, geometry geom, text resample=nearest, integer band=1);

描述

返回与输入几何图形具有相同X/Y坐标的几何图形,并使用请求的重采样算法将栅格中的值复制到Z维度。

这个 resample 参数可设置为“最接近”以复制每个折点所在像元的值,或设置为“双线性”以使用 双线性插值法 以计算也考虑相邻单元格的值。

可用性:3.2.0

示例

--
-- 2x2 test raster with values
--
-- 10 50
-- 40 20
--
WITH test_raster AS (
SELECT
ST_SetValues(
  ST_AddBand(
    ST_MakeEmptyRaster(width => 2, height => 2,
      upperleftx => 0, upperlefty => 2,
      scalex => 1.0, scaley => -1.0,
      skewx => 0, skewy => 0, srid => 4326),
    index => 1, pixeltype => '16BSI',
    initialvalue => 0,
    nodataval => -999),
  1,1,1,
  newvalueset =>ARRAY[ARRAY[10.0::float8, 50.0::float8], ARRAY[40.0::float8, 20.0::float8]]) AS rast
)
SELECT
ST_AsText(
  ST_SetM(
    rast,
    band => 1,
    geom => 'SRID=4326;LINESTRING(1.0 1.9, 1.0 0.2)'::geometry,
    resample => 'bilinear'
))
FROM test_raster

            st_astext
----------------------------------
 LINESTRING M (1 1.9 38,1 0.2 27)

另请参阅

ST_Value, ST_SetZ