get_pixel_line {gdalraster}R Documentation

Raster pixel/line from geospatial x,y coordinates

Description

get_pixel_line() converts geospatial coordinates to pixel/line (raster column, row numbers). The upper left corner pixel is the raster origin (0,0) with column, row increasing left to right, top to bottom.

Usage

get_pixel_line(xy, gt)

Arguments

xy

Numeric array of geospatial x,y coordinates in the same spatial reference system as gt.

gt

Numeric vector of length six. The affine geotransform for the raster.

Value

Integer array of raster pixel/line.

See Also

GDALRaster$getGeoTransform(), inv_geotransform()

Examples

pt_file <- system.file("extdata/storml_pts.csv", package="gdalraster")
## id, x, y in NAD83 / UTM zone 12N
pts <- read.csv(pt_file)
print(pts)
raster_file <- system.file("extdata/storm_lake.lcp", package="gdalraster")
ds <- new(GDALRaster, raster_file)
gt <- ds$getGeoTransform()
get_pixel_line(as.matrix(pts[,-1]), gt)
ds$close()

[Package gdalraster version 1.10.0 Index]