Title: | Data Source Name and Description Helpers for Use With 'GDAL' |
---|---|
Description: | Simple helpers for 'GDAL' data source names ('DSN'), prefix and suffix and other handling. 'GDAL' is the Geospatial Data Abstraction Library, not used by this package directly. |
Authors: | Michael Sumner [aut, cre], Matt Dowle [ctb] (wrote the source code used here in C_addr, originally in data.table) |
Maintainer: | Michael Sumner <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.1.9011 |
Built: | 2024-11-30 07:50:11 UTC |
Source: | https://github.com/hypertidy/dsn |
Return the type name of the GDAL data type.
gdal_datatypes() datatype(x)
gdal_datatypes() datatype(x)
x |
integer as returned by GDAL, or osgeo.gdal.Open().GetDatatype() |
character string of the type name (the name of the constant in GDAL, e.g. GDT_Byte)
datatype(1) names(gdal_datatypes())
datatype(1) names(gdal_datatypes())
Create a set of GCPs (ground control points) from dimension, extent
gcp_extent(dimension, extent = NULL) gcp_extent_arg(gcp)
gcp_extent(dimension, extent = NULL) gcp_extent_arg(gcp)
dimension |
size of grid 'ncol,nrow' |
extent |
extent 'xmin,xmax,ymin,ymax' |
gcp |
ground control point ('col,row,x,y') |
gcp_extent
returns the col,row,x,y values, gcp_extent_arg
returns
formatted as a GDAL 'vrt://' connection string
gcp_extent(c(10, 20)) dsn <- sprintf("vrt://%s?%s", mem(volcano), gcp_extent_arg(gcp_extent(dim(volcano)))) gcp <- gcp_extent(dim(volcano), c(-180, 180, -90, 90)) gcp_extent_arg(gcp)
gcp_extent(c(10, 20)) dsn <- sprintf("vrt://%s?%s", mem(volcano), gcp_extent_arg(gcp_extent(dim(volcano)))) gcp <- gcp_extent(dim(volcano), c(-180, 180, -90, 90)) gcp_extent_arg(gcp)
An array in memory can be referenced by a GDAL data source.
mem( x, extent = NULL, projection = "", PIXELOFFSET = 0L, LINEOFFSET = 0L, BANDOFFSET = 1L )
mem( x, extent = NULL, projection = "", PIXELOFFSET = 0L, LINEOFFSET = 0L, BANDOFFSET = 1L )
x |
an R array, must be of numeric type (integer is converted to double) |
extent |
optional extent of the data in x,y c(xmin, xmax, ymin, ymax) |
projection |
projection string (optional, sets the SPATIALREFERENCE of the MEM driver since GDAL 3.7) |
This DSN will only work in R, and is only for use with GDAL read and query tools (so terra, sf, gdalcubes, vapour, etc.).
character string, a DSN for use by GDAL
m <- matrix(as.integer(c(0L, 0, 0, 1)), 5L, 4L) mem(m) mem(volcano)
m <- matrix(as.integer(c(0L, 0, 0, 1)), 5L, 4L) mem(m) mem(volcano)
Add required prefixes, or remove them.
vsicurl(x, sign = FALSE) driver(x, driver = "") netcdf(x) unprefix(x) unvsicurl(x)
vsicurl(x, sign = FALSE) driver(x, driver = "") netcdf(x) unprefix(x) unvsicurl(x)
x |
character vector, of data source names (file paths, urls, database connection strings, or GDAL dsn) |
sign |
configure for automatic Planetary Computer signing by GDAL |
driver |
character vector of appropriate GDAL driver name |
character vector
vsicurl("https://netcdf-r-us.org/f.nc") driver("somefile.h5", "HDF5") unvsicurl("/vsicurl/https://netcdf-r-us.org/f.nc") unprefix("NETCDF:/u/user/somefile.nc") ## MPC signing mpc <- "https://sentinel2l2a01.blob.core.windows.net/sentinel2-l2/.../T43DFE_B04_10m.tif" vsicurl(mpc , sign = TRUE)
vsicurl("https://netcdf-r-us.org/f.nc") driver("somefile.h5", "HDF5") unvsicurl("/vsicurl/https://netcdf-r-us.org/f.nc") unprefix("NETCDF:/u/user/somefile.nc") ## MPC signing mpc <- "https://sentinel2l2a01.blob.core.windows.net/sentinel2-l2/.../T43DFE_B04_10m.tif" vsicurl(mpc , sign = TRUE)
Subdataset and VRT connection strings.
sds(x, varname, driver, quote = TRUE)
sds(x, varname, driver, quote = TRUE)
x |
character vector, of data source names (file paths, urls, database connection strings, or GDAL dsn) |
varname |
named of variable in DSN |
driver |
driver to use, e.g. "NETCDF", "HDF5" |
quote |
wrap the core dsn in escaped double quotes, or not |
character string of the form "DRIVER:%s:varname"
f <- "myfile.nc" sds(f, "variable", "NETCDF", quote = FALSE)
f <- "myfile.nc" sds(f, "variable", "NETCDF", quote = FALSE)
Create a vrt connection from an input string and named arguments.
vrtcon(x, ...)
vrtcon(x, ...)
x |
character vector, of data source names (file paths, urls, database connection strings, or GDAL dsn) |
... |
named arguments like 'a_srs="OGC:CRS84" |
As of writing (GDAL 3.7.0DEV 2022-12-12) the only available named arguments are 'a_srs', 'bands', 'a_ullr' but that doesn't stop this function.
character string in the form "vrt://%s?arg1&arg2"
vrtcon("myfile.nc", a_ullr = "0,90,360,-90", bands="1,2,1")
vrtcon("myfile.nc", a_ullr = "0,90,360,-90", bands="1,2,1")