Name

ST_Transform — Projiziert einen Raster von einem bekannten Koordinatenreferenzsystem in ein anderes bekanntes Koordinatenreferenzsystem um. Die Optionen für die Skalierung sind NearestNeighbor, Bilinear, Cubisch, CubicSpline und der Lanczos-Filter, die Standardeinstellung ist NearestNeighbor.

Synopsis

raster ST_Transform(raster rast, integer srid, text algorithm=NearestNeighbor, double precision maxerr=0.125, double precision scalex, double precision scaley);

raster ST_Transform(raster rast, integer srid, double precision scalex, double precision scaley, text algorithm=NearestNeighbor, double precision maxerr=0.125);

raster ST_Transform(raster rast, raster alignto, text algorithm=NearestNeighbor, double precision maxerr=0.125);

Beschreibung

Projiziert einen Raster von einem bekannten Koordinatenreferenzsystem in ein anderes bekanntes Koordinatenreferenzsystem um. Verwendet den angegebenen Algorithmus für die Interpolation der Pixelwerte. Wenn kein Algorithmus angegeben ist, wird 'NearestNeighbor' verwendet. Wenn "maxerr" nicht angegeben ist, wird ein Prozentsatz von 0.125 angenommen.

Die Optionen für den Algorithmus sind: 'NearestNeighbor', 'Bilinear', 'Cubic', 'CubicSpline' und 'Lanczos'. Siehe GDAL Warp resampling methods für weitere Details.

ST_Transform wird oft mit ST_SetSRID() verwechselt. ST_Transform ändert die Koordinaten der Geometrie tatsächlich (und die Pixelwerte mittels "resampling") von einem Koordinatenreferenzsystem auf ein anderes, während ST_SetSRID() nur den Identifikator "SRID" des Rasters ändert.

Anders als die anderen Varianten, benötigt Variante 3 einen Referenzraster für den Parameter alignto. Der Raster wird in das Koordinatenreferenzsystem (SRID) des Referenzrasters transformiert und an dem Referenzraster ausgerichtet (ST_SameAlignment = TRUE).

[Note]

If you find your transformation support is not working right, you may need to set the environment variable PROJSO to the .so or .dll projection library your PostGIS is using. This just needs to have the name of the file. So for example on windows, you would in Control Panel -> System -> Environment Variables add a system variable called PROJSO and set it to libproj.dll (if you are using proj 4.6.1). You'll have to restart your PostgreSQL service/daemon after this change.

[Warning]

When transforming a coverage of tiles, you almost always want to use a reference raster to insure same alignment and no gaps in your tiles as demonstrated in example: Variant 3.

Verfügbarkeit: 2.0.0 benötigt GDAL 1.6.1+

Erweiterung: 2.1.0 Variante ST_Transform(rast, alignto) hinzugefügt

Beispiele

SELECT ST_Width(mass_stm) As w_before, ST_Width(wgs_84) As w_after,
  ST_Height(mass_stm) As h_before, ST_Height(wgs_84) As h_after
    FROM
    ( SELECT rast As mass_stm, ST_Transform(rast,4326) As wgs_84
  ,  ST_Transform(rast,4326, 'Bilinear') AS wgs_84_bilin
        FROM aerials.o_2_boston
            WHERE ST_Intersects(rast,
                ST_Transform(ST_MakeEnvelope(-71.128, 42.2392,-71.1277, 42.2397, 4326),26986) )
        LIMIT 1) As foo;

 w_before | w_after | h_before | h_after
----------+---------+----------+---------
      200 |     228 |      200 |     170
                    

ursprüngliche "Mass State Plane Meters" (mass_stm)

Nach der Transformation in WGS 84 Länge Breite (wgs_84)

Koordinatentransformation nach WGS 84 mit dem bilinearen Algorithmus anstelle der Standardeinstellung NN (wgs_84_bilin)

Beispiele: Variante 3

Im Folgenden wird der Unterschied zwischen der Verwendung von ST_Transform(raster, srid) und ST_Transform(raster, alignto) gezeigt

WITH foo AS (
    SELECT 0 AS rid, ST_AddBand(ST_MakeEmptyRaster(2, 2, -500000, 600000, 100, -100, 0, 0, 2163), 1, '16BUI', 1, 0) AS rast UNION ALL
    SELECT 1, ST_AddBand(ST_MakeEmptyRaster(2, 2, -499800, 600000, 100, -100, 0, 0, 2163), 1, '16BUI', 2, 0) AS rast UNION ALL
    SELECT 2, ST_AddBand(ST_MakeEmptyRaster(2, 2, -499600, 600000, 100, -100, 0, 0, 2163), 1, '16BUI', 3, 0) AS rast UNION ALL

    SELECT 3, ST_AddBand(ST_MakeEmptyRaster(2, 2, -500000, 599800, 100, -100, 0, 0, 2163), 1, '16BUI', 10, 0) AS rast UNION ALL
    SELECT 4, ST_AddBand(ST_MakeEmptyRaster(2, 2, -499800, 599800, 100, -100, 0, 0, 2163), 1, '16BUI', 20, 0) AS rast UNION ALL
    SELECT 5, ST_AddBand(ST_MakeEmptyRaster(2, 2, -499600, 599800, 100, -100, 0, 0, 2163), 1, '16BUI', 30, 0) AS rast UNION ALL

    SELECT 6, ST_AddBand(ST_MakeEmptyRaster(2, 2, -500000, 599600, 100, -100, 0, 0, 2163), 1, '16BUI', 100, 0) AS rast UNION ALL
    SELECT 7, ST_AddBand(ST_MakeEmptyRaster(2, 2, -499800, 599600, 100, -100, 0, 0, 2163), 1, '16BUI', 200, 0) AS rast UNION ALL
    SELECT 8, ST_AddBand(ST_MakeEmptyRaster(2, 2, -499600, 599600, 100, -100, 0, 0, 2163), 1, '16BUI', 300, 0) AS rast
), bar AS (
    SELECT
        ST_Transform(rast, 4269) AS alignto
    FROM foo
    LIMIT 1
), baz AS (
    SELECT
        rid,
        rast,
        ST_Transform(rast, 4269) AS not_aligned,
        ST_Transform(rast, alignto) AS aligned
    FROM foo
    CROSS JOIN bar
)
SELECT
    ST_SameAlignment(rast) AS rast,
    ST_SameAlignment(not_aligned) AS not_aligned,
    ST_SameAlignment(aligned) AS aligned
FROM baz

 rast | not_aligned | aligned
------+-------------+---------
 t    | f           | t
                

not_aligned

aligned

Siehe auch

ST_Transform, ST_SetSRID