Skip to main content
Returns the grid coordinate of the given world coordinates as a Point. RS_WorldToRasterCoord

Signatures

RS_WorldToRasterCoord(raster: Raster, point: Geometry)
RS_WorldToRasterCoord(raster: Raster, x: Double, y: Point)

Parameters

raster
Raster
required
The input raster.
x
Double
The X coordinate (longitude).
y
Double
The Y coordinate (latitude).
point
Geometry
The point value.

Return type

The resulting geometry.

Examples

SELECT RS_WorldToRasterCoord(ST_MakeEmptyRaster(1, 5, 5, -53, 51, 1, -1, 0, 0, 4326), -53, 51) from rasters;
POINT (1 1)
SELECT RS_WorldToRasterCoord(ST_MakeEmptyRaster(1, 5, 5, -53, 51, 1, -1, 0, 0, 4326), ST_GeomFromText('POINT (-52 51)')) from rasters;
POINT (2 1)
If the given geometry point is not in the same CRS as the given raster, the given geometry will be transformed to the given raster’s CRS. You can use ST_Transform to transform the geometry beforehand.