名称

ST_RasterToWorldCoordX — 返回栅格左上角的几何 X 坐标、列和行。列和行的编号从 1 开始。

语法

float8 ST_RasterToWorldCoordX(raster rast, integer xcolumn);

float8 ST_RasterToWorldCoordX(raster rast, integer xcolumn, integer yrow);

说明

以地理参考栅格的几何单位返回栅格行列的左上角 X 坐标。列和行的编号从 1 开始,但如果您传入负数或高于栅格中列数的数字,它将为您提供栅格文件外部的坐标,向左或向右,假设倾斜度和像素大小与所选栅格相同。

[Note]

对于非倾斜栅格,提供 X 列就足够了。对于倾斜栅格,地理参考坐标是 ST_ScaleX 和 ST_SkewX 以及行和列的函数。如果您只为倾斜栅格提供 X 列,则会引发错误。

已更改:2.1.0 在之前的版本中,这称为 ST_Raster2WorldCoordX

示例

-- non-skewed raster providing column is sufficient
SELECT rid, ST_RasterToWorldCoordX(rast,1) As x1coord,
    ST_RasterToWorldCoordX(rast,2) As x2coord,
    ST_ScaleX(rast) As pixelx
FROM dummy_rast;

 rid |  x1coord   |  x2coord  | pixelx
-----+------------+-----------+--------
   1 |        0.5 |       2.5 |      2
   2 | 3427927.75 | 3427927.8 |   0.05
                
-- for fun lets skew it
SELECT rid, ST_RasterToWorldCoordX(rast, 1, 1) As x1coord,
    ST_RasterToWorldCoordX(rast, 2, 3) As x2coord,
    ST_ScaleX(rast) As pixelx
FROM (SELECT rid, ST_SetSkew(rast, 100.5, 0) As rast FROM dummy_rast) As foo;

 rid |  x1coord   |  x2coord  | pixelx
-----+------------+-----------+--------
   1 |        0.5 |     203.5 |      2
   2 | 3427927.75 | 3428128.8 |   0.05
                

另请参阅

ST_ScaleXST_RasterToWorldCoordYST_SetSkewST_SkewX