Title: | Helpers for the 'GDAL' Application Utility Libraries |
---|---|
Description: | Helpful wrappers around the GDAL utilities, for now via the 'sf' package. |
Authors: | Michael D. Sumner [aut, cre] |
Maintainer: | Michael D. Sumner <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9001 |
Built: | 2024-11-08 02:40:38 UTC |
Source: | https://github.com/hypertidy/futility |
Runs the gdal_grid utility.
gdal_grid( pts, dimension = c(256, 256), extent = NULL, algorithm = "linear", read = TRUE, options = NULL )
gdal_grid( pts, dimension = c(256, 256), extent = NULL, algorithm = "linear", read = TRUE, options = NULL )
pts |
points, columns of X, Y, Z |
dimension |
ncols, nrows |
extent |
xmin,xmax,ymin,ymax |
algorithm |
one of invdist, invdistnn, average, linear see Details |
Algorithms listed at https://gdal.org/programs/gdal_grid.html#interpolation-algorithmsuse
Pass in paramaters the algorithm name, e. g. 'invdist:power=2.0:smoothing=1.0' - see examples.
matrix of raster values, numeric
n <- 500 rc <- cbind(sample(nrow(volcano), n, replace = TRUE), sample(ncol(volcano), n, replace = TRUE)) xyz <- cbind(rc, volcano[rc]) ex <- c(range(xyz[,1]), range(xyz[,2])) v <- gdal_grid(xyz, extent = ex) ximage::ximage(v, extent = ex, asp = 1) v1 <- gdal_grid(xyz, extent = ex, algorithm = "invdist:power=2.0:smoothing=1.0 ")
n <- 500 rc <- cbind(sample(nrow(volcano), n, replace = TRUE), sample(ncol(volcano), n, replace = TRUE)) xyz <- cbind(rc, volcano[rc]) ex <- c(range(xyz[,1]), range(xyz[,2])) v <- gdal_grid(xyz, extent = ex) ximage::ximage(v, extent = ex, asp = 1) v1 <- gdal_grid(xyz, extent = ex, algorithm = "invdist:power=2.0:smoothing=1.0 ")
Obtain a filename that wraps a CSV file with the input points in it. This is suitable
for use with gdal_grid the command line utility, but see gdal_grid()
the function
for a convenient wrapper.
vrtpoints(pts, name = NULL)
vrtpoints(pts, name = NULL)
pts |
data frame or matrix of points, X, Y, Z |
name |
optional, used as the layername in the GDAL source |
path to tempfile
n <- 500 rc <- cbind(sample(nrow(volcano), n, replace = TRUE), sample(ncol(volcano), n, replace = TRUE)) xyz <- cbind(rc, volcano[rc]) plot(xyz[,2:1], col = palr::d_pal(xyz[,3]), pch = 19, cex = .3) file <- vrtpoints(xyz) sf::gdal_utils("grid", file, tf <- tempfile(fileext = ".tif")) sf::read_sf(file) sf::gdal_utils("info", tf)
n <- 500 rc <- cbind(sample(nrow(volcano), n, replace = TRUE), sample(ncol(volcano), n, replace = TRUE)) xyz <- cbind(rc, volcano[rc]) plot(xyz[,2:1], col = palr::d_pal(xyz[,3]), pch = 19, cex = .3) file <- vrtpoints(xyz) sf::gdal_utils("grid", file, tf <- tempfile(fileext = ".tif")) sf::read_sf(file) sf::gdal_utils("info", tf)