ST_PixelWidth — Повертає ширину пікселя в геометричних одиницях просторової системи координат.
double precision ST_PixelWidth(raster rast);
Повертає ширину пікселя в геометричних одиницях просторової системи координат. У звичайному випадку, коли немає нахилу, ширина пікселя дорівнює співвідношенню масштабу між геометричними координатами та растровими пікселями.
The following executable example draws the two pixel basis vectors on the same coordinate frame as a skewed raster footprint. The i direction vector is (scaleX, skewY); the j direction vector is (skewX, scaleY).
Pixel basis vectors and footprint for a raster with non-zero skew.
WITH raster AS (
SELECT ST_MakeEmptyRaster(
3, 3, 0, 0,
2, -3, 1, 0.5,
0
) AS rast
)
SELECT
ST_ConvexHull(rast) AS footprint,
ST_MakeLine(
ST_Point(0, 0),
ST_Point(ST_ScaleX(rast), ST_SkewY(rast))
) AS "i direction (scaleX, skewY)",
ST_MakeLine(
ST_Point(0, 0),
ST_Point(ST_SkewX(rast), ST_ScaleY(rast))
) AS "j direction (skewX, scaleY)"
FROM raster;
POLYGON((0 0,6 1.5,9 -7.5,3 -9,0 0)) | LINESTRING(0 0,2 0.5) | LINESTRING(0 0,1 -3)
Rasters with no skew.
SELECT ST_Width(rast) As rastwidth, ST_PixelWidth(rast) As pixwidth, ST_ScaleX(rast) As scalex, ST_ScaleY(rast) As scaley, ST_SkewX(rast) As skewx, ST_SkewY(rast) As skewy FROM dummy_rast;
rastwidth | pixwidth | scalex | scaley | skewx | skewy -----------+----------+--------+--------+-------+---------- 10 | 2 | 2 | 3 | 0 | 0 5 | 0.05 | 0.05 | -0.05 | 0 | 0
Rasters with skew different than 0.
SELECT ST_Width(rast) As rastwidth, ST_PixelWidth(rast) As pixwidth, ST_ScaleX(rast) As scalex, ST_ScaleY(rast) As scaley, ST_SkewX(rast) As skewx, ST_SkewY(rast) As skewy FROM (SELECT ST_SetSkew(rast, 0.5, 0.5) As rast FROM dummy_rast) As skewed;
rastwidth | pixwidth | scalex | scaley | skewx | skewy -----------+-------------------+--------+--------+-------+---------- 10 | 2.06155281280883 | 2 | 3 | 0.5 | 0.5 5 | 0.502493781056044 | 0.05 | -0.05 | 0.5 | 0.5