Skip to content

RS_WorldToRasterCoordX

Converts world coordinates to raster X coordinate.

Usage

integer RS_WorldToRasterCoordX(rast: raster, x: double, y: double)
integer RS_WorldToRasterCoordX(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_WorldToRasterCoordX(RS_Example(), 10.0, 20.0);
┌──────────────────────────────────────────────────────────────┐
│ rs_worldtorastercoordx(rs_example(),Float64(10),Float64(20)) │
│                             int64                            │
╞══════════════════════════════════════════════════════════════╡
│                                                           -1 │
└──────────────────────────────────────────────────────────────┘

The world coordinate can also be given as a point:

SELECT RS_WorldToRasterCoordX(RS_Example(), ST_Point(10.0, 20.0));
┌────────────────────────────────────────────────────────────────────────┐
│ rs_worldtorastercoordx(rs_example(),st_point(Float64(10),Float64(20))) │
│                                  int64                                 │
╞════════════════════════════════════════════════════════════════════════╡
│                                                                     -1 │
└────────────────────────────────────────────────────────────────────────┘