Skip to content

RS_WorldToRasterCoord

Converts world coordinates to raster coordinates as a point.

Usage

geometry RS_WorldToRasterCoord(rast: raster, x: double, y: double)
geometry RS_WorldToRasterCoord(rast: raster, point: geometry)

Arguments

  • rast (raster): Input raster
  • point (geometry): The world coordinate is read from this point. Its coordinates are used as given, in the raster’s own space — this form does not reproject.
  • x (double)
  • y (double)

Description

The result is a 1-based pixel coordinate, as in PostGIS ST_WorldToRasterCoord: a world coordinate inside the upper-left pixel maps to (1, 1). A world coordinate outside the raster extrapolates along the geotransform, so it can map to 0 or a negative coordinate.

Examples

SELECT RS_WorldToRasterCoord(RS_Example(), 10.0, 20.0);
┌─────────────────────────────────────────────────────────────┐
│ rs_worldtorastercoord(rs_example(),Float64(10),Float64(20)) │
│                           geometry                          │
╞═════════════════════════════════════════════════════════════╡
│ POINT(-1 -27)                                               │
└─────────────────────────────────────────────────────────────┘

The world coordinate can also be given as a point:

SELECT RS_WorldToRasterCoord(RS_Example(), ST_Point(10.0, 20.0));
┌───────────────────────────────────────────────────────────────────────┐
│ rs_worldtorastercoord(rs_example(),st_point(Float64(10),Float64(20))) │
│                                geometry                               │
╞═══════════════════════════════════════════════════════════════════════╡
│ POINT(-1 -27)                                                         │
└───────────────────────────────────────────────────────────────────────┘