Description Usage Arguments Value Author(s) Examples
This function helps to extract dates from a vector of files.
1 | extractDate(files, pos1, pos2, asDate = FALSE, format = "%Y%j")
|
files |
A |
pos1, pos2 |
Start and end of date string in |
asDate |
|
format |
|
A list
with the following entries: 'inputLayerDates', 'pos1', 'pos2',
'asDate' and, optionally, 'format'. If asDate = FALSE
,
'inputLayerDates' are represented as character
, else as Date
.
Matteo Mattiuzzi
1 2 3 4 5 6 7 8 9 10 11 | # example on HDF files
files <- c("MOD13Q1.A2010209.h18v03.005.2010239071130.hdf",
"MOD13Q1.A2010225.h18v03.005.2010254043849.hdf")
extractDate(files)
extractDate(files, asDate = TRUE)
# on any other file
files <- c("Myfile_20010101.XXX", "Myfile_20010115.XXX", "Myfile_20010204.XXX")
extractDate(files, pos1 = 8, pos2 = 15)
extractDate(files, pos1 = 8, pos2 = 15, asDate = TRUE, format = "%Y%m%d")
|
Loading required package: mapdata
Loading required package: maps
Loading required package: raster
Loading required package: sp
Warning message:
In file(con, "r") : cannot open file '/proc/stat': Permission denied
$inputLayerDates
MOD13Q1.A2010209.h18v03.005.2010239071130.hdf
"2010209"
MOD13Q1.A2010225.h18v03.005.2010254043849.hdf
"2010225"
$pos1
[1] 10 10
$pos2
[1] 16 16
$asDate
[1] FALSE
$inputLayerDates
[1] "2010-07-28" "2010-08-13"
$pos1
[1] 10 10
$pos2
[1] 16 16
$asDate
[1] TRUE
$format
[1] "%Y%j"
$inputLayerDates
Myfile_20010101.XXX Myfile_20010115.XXX Myfile_20010204.XXX
"20010101" "20010115" "20010204"
$pos1
[1] 8
$pos2
[1] 15
$asDate
[1] FALSE
$inputLayerDates
[1] "2001-01-01" "2001-01-15" "2001-02-04"
$pos1
[1] 8
$pos2
[1] 15
$asDate
[1] TRUE
$format
[1] "%Y%m%d"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.