Reads and parses the header of a test file as available through the ASTER reflectance database. The Name field is retrieved and copied to attribute "what.measured". The header of the file is preserved as a comment.
Usage
read_ASTER_txt(
file,
date = NULL,
geocode = NULL,
label = NULL,
tz = NULL,
locale = readr::default_locale(),
npixels = Inf
)
Arguments
- file
character string
- date
a
POSIXct
object to use to set the"when.measured"
attribute. IfNULL
, the default, the date is extracted from the file header.- geocode
A data frame with columns
lon
andlat
used to set attribute"where.measured"
.- label
character string, but if
NULL
the value offile
is used, and ifNA
the "what.measured" attribute is not set.- tz
character Ignored.
- locale
The locale controls defaults that vary from place to place. The default locale is US-centric (like R), but you can use
locale
to create your own locale that controls things like the default time zone, encoding, decimal mark, big mark, and day/month names.- npixels
integer Number of pixels in spectral data.
Note
The header in these files has metadata information, but mostly on the
origin of the data. For a date and/or geocode are to be added to the return
object it must be supplied by the user. as well as the date-time. Some
metadata is extracted and added as attributes, while the whole header is
copied to the comment
attribute.
References
Baldridge, A.; Hook, S.; Grove, C. & Rivera, G. (2009) The ASTER spectral library version 2.0. Remote Sensing of Environment. 113, 711-715
Examples
file.name <-
system.file("extdata", "drygrass-spectrum.txt",
package = "photobiologyInOut", mustWork = TRUE)
fred.spct <- read_ASTER_txt(file = file.name, npixels = Inf)
fred.spct
#> Object: reflector_spct [2,559 x 2]
#> Wavelength range 380.49-14011 nm, step 0.8-38 nm
#> Label: Name: Dry grass
#> File: drygrass-spectrum.txt
#> Variables:
#> w.length: Wavelength [nm]
#> Rfr: Total spectral reflectance [/1]
#> --
#> # A tibble: 2,559 × 2
#> w.length Rfr
#> <dbl> <dbl>
#> 1 380. 0.142
#> 2 383. 0.143
#> 3 385. 0.145
#> 4 388. 0.147
#> 5 390. 0.148
#> 6 393. 0.150
#> 7 395. 0.153
#> 8 398. 0.154
#> 9 400. 0.157
#> 10 403. 0.159
#> # ℹ 2,549 more rows
getWhatMeasured(fred.spct)
#> [1] "Name: Dry grass\nFile: drygrass-spectrum.txt"
cat(comment(fred.spct))
#> ASTER database file 'drygrass-spectrum.txt' imported on 2025-03-10 15:48:17.254473 UTC
#> Name: Dry grass
#> Type: Vegetation
#> Class: Grasses
#> Subclass: Dry grass
#> Particle Size: Solid
#> Sample No.: drygrass.doc
#> Owner: JHU
#> Wavelength Range: All
#> Origin: The entire spectral range was measured at Johns Hopkins University.
#> Description: Dry grass. Spectra were assembled from two segments; the
#> bidirectional VNIR and SWIR comprising segment one, and the hemispherical
#> MWIR and TIR comprising segment two. The VNIR/SWIR spectrum was
#> measured in the laboratory at JHU with a GER IRIS Mark IV, using a large piece
#> of sod. The grass was illuminated from directly above and measured at a
#> reflectance angle of 60 degrees to avoid viewing the thatch.
#> Measurement: Bidirectional and directional hemispherical reflectance.
#> First Column: X
#> Second Column: Y
#> X Units: Wavelength (micrometers)
#> Y Units: Reflectance (percent)
#> First X Value: 0.38049
#> Last X Value: 14.011
#> Number of X Values: 2559
#> Additional Information: None.
#>