pixel_to_xy() takes pixel and line positions to georeferenced ones, and
xy_to_pixel() takes them back again.
Arguments
- geotransform
A numeric vector of length 6, as a dataset's
geotransformproperty returns.- pixel, line
Numeric vectors of the same length. Fractional positions are meaningful: whole numbers fall on pixel corners, so the centre of the first pixel is
pixel = 0.5, line = 0.5.- x, y
Numeric vectors of the same length, in the dataset's coordinate reference system.
Examples
ds <- gdal_open(system.file("extdata/test.tif", package = "GDAL7"))
gt <- ds@geotransform
# The centre of the first pixel, and back again.
pixel_to_xy(gt, 0.5, 0.5)
#> $x
#> [1] -171
#>
#> $y
#> [1] 81
#>
xy_to_pixel(gt, -180 + 9, 90 - 9)
#> $pixel
#> [1] 0.5
#>
#> $line
#> [1] 0.5
#>
gdal_close(ds)