ST_SnapToGrid
Name
ST_SnapToGrid — Resample a raster by snapping it to a grid. New pixel values are computed using the NearestNeighbor (english or american spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. Default is NearestNeighbor.
Synopsis
raster
ST_SnapToGrid
(
raster
rast
, double precision
gridx
, double precision
gridy
, text
algorithm=NearestNeighbour
, double precision
maxerr=0.125
, double precision
scalex=DEFAULT 0
, double precision
scaley=DEFAULT 0
)
;
raster
ST_SnapToGrid
(
raster
rast
, double precision
gridx
, double precision
gridy
, double precision
scalex
, double precision
scaley
, text
algorithm=NearestNeighbour
, double precision
maxerr=0.125
)
;
raster
ST_SnapToGrid
(
raster
rast
, double precision
gridx
, double precision
gridy
, double precision
scalexy
, text
algorithm=NearestNeighbour
, double precision
maxerr=0.125
)
;
Description
Resample a raster by snapping it to a grid defined by an arbitrary pixel corner (gridx & gridy) and optionally a pixel size (scalex & scaley). New pixel values are computed using the NearestNeighbor (english or american spelling), Bilinear, Cubic, CubicSpline or Lanczos resampling algorithm. The default is NearestNeighbor which is the fastest but results in the worst interpolation.
gridx
and
gridy
define any arbitrary pixel corner of the new grid. This is not necessarily the upper left corner of the new raster and it does not have to be inside or on the edge of the new raster extent.
You can optionnal define the pixel size of the new grid with
scalex
and
scaley
.
The extent of the new raster will encompass the extent of the provided raster.
A maxerror percent of 0.125 if no
maxerr
is specified.
Refer to: GDAL Warp resampling methods for more details. |
Use ST_Resample if you need more control over the grid parameters. |
Availability: 2.0.0 Requires GDAL 1.6.1+
Changed: 2.1.0 Works on rasters with no SRID
Examples
A simple example snapping a raster to a slightly different grid.
-- the original raster upper left X SELECT ST_UpperLeftX(ST_AddBand(ST_MakeEmptyRaster(10, 10, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BUI'::text, 1, 0)); -- result 0 -- the upper left of raster after snapping SELECT ST_UpperLeftX(ST_SnapToGrid(ST_AddBand(ST_MakeEmptyRaster(10, 10, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BUI'::text, 1, 0), 0.0002, 0.0002)); --result -0.0008