名稱

ST_SetM — 返回一個幾何圖形,其 X/Y 座標與輸入幾何圖形相同,並使用請求的重採樣演算法將柵格的值複製到 M 維度中。

概要

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

描述

返回一個幾何圖形,其 X/Y 座標與輸入幾何圖形相同,並使用請求的重採樣演算法將柵格的值複製到 M 維度中。

resample 參數可以設定為 "nearest",以複製每個頂點落入的單元格的值;或設定為 "bilinear",使用雙線性內插來計算一個也將相鄰單元格考慮在內的值。

可用性: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_ValueST_SetZ