Package 'futility'

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-09-09 02:54:50 UTC
Source: https://github.com/hypertidy/futility

Help Index


GDAL grid

Description

Runs the gdal_grid utility.

Usage

gdal_grid(
  pts,
  dimension = c(256, 256),
  extent = NULL,
  algorithm = "linear",
  read = TRUE,
  options = NULL
)

Arguments

pts

points, columns of X, Y, Z

dimension

ncols, nrows

extent

xmin,xmax,ymin,ymax

algorithm

one of invdist, invdistnn, average, linear see Details

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.

Value

matrix of raster values, numeric

Examples

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 ")

Write points xyz to CSV for GDAL.

Description

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.

Usage

vrtpoints(pts, name = NULL)

Arguments

pts

data frame or matrix of points, X, Y, Z

name

optional, used as the layername in the GDAL source

Value

path to tempfile

Examples

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)