ST_SetZ — 返回一個幾何物件,其 X/Y 坐標與輸入幾何物件相同,並使用請求的重採樣算法將柵格中的值複製到 Z 維度中。
geometry ST_SetZ(
raster rast, geometry geom, text resample=nearest, integer band=1)
;
返回一個幾何物件,其 X/Y 坐標與輸入幾何物件相同,並使用請求的重採樣算法將柵格中的值複製到 Z 維度中。
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_SetZ( rast, band => 1, geom => 'SRID=4326;LINESTRING(1.0 1.9, 1.0 0.2)'::geometry, resample => 'bilinear' )) FROM test_raster st_astext ---------------------------------- LINESTRING Z (1 1.9 38,1 0.2 27)