rasterInfo | R Documentation |
This is a wrapper for the gdalinfo utility (accessed through either sf::gdal_utils or terra::describe) that returns parsed output in a nested list.
rasterInfo(x)
## S3 method for class 'rasterInfo'
print(x, all = FALSE, raw = FALSE, ...)
x |
For raster info the path to a raster file.
For the print method a |
all |
if |
raw |
if |
... |
required by generic method. |
This is a work in progress. The information returned by gdalinfo depends on
the file type described and I've developed this while working primarily with
single band ArcInfo Grids and geoTIFF files so this function is unlikely to
parse all available information for all file types.
Use print(rasterInfo(x), raw = TRUE)
, x$raw
if x
is a
rasterInfo
object, to see the original text.
Some return values aren't standard for gdal but are calculated here from
other values (e.g. cellsize
, type
, extent
).
A nested list of class rasterInfo
with most of the
information returned by gdalinfo (terra::describe()
) and some additional
derived elements.
path |
The path to the raster file, same as |
driver |
The driver used to read the file which usually matches the file's format |
type |
Calculated from |
res |
the resolution of the cells, as reported gdal (two dimensions, possible negative) |
cellsize |
calculated from |
na.value |
|
dim |
The dimensions of the raster in cells (rows, then cols). This is from a raw line that reads "Size is" and reports cols then rows (reverse of order used here). |
rows |
the number of rows in the file (copied from |
cols |
the number of columns in the file (copied from |
origin |
the coordinates of the origin of the file (this seems to be the upper left corner). Note, gdal may report more digits than R can represent. Look at raw output to see the text as reported by gdal |
approx.coords |
the approximate coordinates of the corners and center.
This is reported by |
extent |
A list with items |
nbands |
The number of bands in the file. |
bands |
A list of lists (one per band); inner list has items
|
metadata |
any file metadata |
imagestructuremetadata |
any file image structure metadata |
crs |
The coordinate reference system in well known text format |
files |
a vector of all the files associated with the raster dataset |
attributetable |
the raster attribute table (AKA Value Attribute Table, VAT) |
raw |
The raw text returned by gdalinfo that was parsed to create all other items in this list |
The print
method for rasterInfo
will, by default, skip some
potentially large components. Use print(x, all = TRUE)
to print
everything but the raw text; or print(x, raw = TRUE)
to print the
raw text only. If the raster file is missing, corrupt, or otherwise
unreadable by gdal type
will be "missing"
, path
will
be the input path, and all other items in the returned list will be
NA
.
https://gdal.org/programs/gdalinfo.html
tif <- system.file("extdata","slope.tif" , package = "rasterPrep")
rasterInfo(tif)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.