apply_geotransform | R Documentation |
apply_geotransform()
applies geotransform coefficients to raster
coordinates in pixel/line space (column/row), converting into
georeferenced (x/y) coordinates. Wrapper of GDALApplyGeoTransform()
in
the GDAL API, operating on matrix input.
apply_geotransform(col_row, gt)
col_row |
Numeric matrix of raster column/row (pixel/line) coordinates (or two-column data frame that will be coerced to numeric matrix). |
gt |
Either a numeric vector of length six containing the affine
geotransform for the raster, or an object of class |
Numeric matrix of geospatial x/y coordinates.
Bounds checking on the input coordinates is done if gt
is obtained from an
object of class GDALRaster
. See Note for get_pixel_line()
.
GDALRaster$getGeoTransform()
, get_pixel_line()
raster_file <- system.file("extdata/storm_lake.lcp", package="gdalraster")
ds <- new(GDALRaster, raster_file)
# compute some raster coordinates in column/row space
set.seed(42)
col_coords <- runif(10, min = 0, max = ds$getRasterXSize() - 0.00001)
row_coords <- runif(10, min = 0, max = ds$getRasterYSize() - 0.00001)
col_row <- cbind(col_coords, row_coords)
# convert to geospatial x/y coordinates
gt <- ds$getGeoTransform()
apply_geotransform(col_row, gt)
# or, using the class method
ds$apply_geotransform(col_row)
# bounds checking
col_row <- rbind(col_row, c(ds$getRasterXSize(), ds$getRasterYSize()))
ds$apply_geotransform(col_row)
ds$close()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.