Convert tidy MODISTools data to a raster (stack)

mt_to_raster(df, reproject = FALSE)

Arguments

df

a valid MODISTools data frame with a single band (filter for a particular band using the dplyr filter() function or base subset()

reproject

reproject output to lat / long (default = FALSE)

Value

A raster stack populated with the tidy dataframe values

See also

Examples

# \donttest{ # list all available MODIS Land Products Subsets products # download data LC <- mt_subset(product = "MCD12Q1", lat = 48.383662, lon = 2.610250, band = "LC_Type1", start = "2005-01-01", end = "2005-12-30", km_lr = 2, km_ab = 2, site_name = "testsite", internal = TRUE, progress = FALSE) head(LC)
#> xllcorner yllcorner cellsize nrows ncols band units scale #> 1.1 190884.84 5378134.05 463.312716528 9 9 LC_Type1 class Not Available #> 1.2 190884.84 5378134.05 463.312716528 9 9 LC_Type1 class Not Available #> 1.3 190884.84 5378134.05 463.312716528 9 9 LC_Type1 class Not Available #> 1.4 190884.84 5378134.05 463.312716528 9 9 LC_Type1 class Not Available #> 1.5 190884.84 5378134.05 463.312716528 9 9 LC_Type1 class Not Available #> 1.6 190884.84 5378134.05 463.312716528 9 9 LC_Type1 class Not Available #> latitude longitude site product start end complete #> 1.1 48.38366 2.61025 testsite MCD12Q1 2005-01-01 2005-12-30 TRUE #> 1.2 48.38366 2.61025 testsite MCD12Q1 2005-01-01 2005-12-30 TRUE #> 1.3 48.38366 2.61025 testsite MCD12Q1 2005-01-01 2005-12-30 TRUE #> 1.4 48.38366 2.61025 testsite MCD12Q1 2005-01-01 2005-12-30 TRUE #> 1.5 48.38366 2.61025 testsite MCD12Q1 2005-01-01 2005-12-30 TRUE #> 1.6 48.38366 2.61025 testsite MCD12Q1 2005-01-01 2005-12-30 TRUE #> modis_date calendar_date tile proc_date pixel value #> 1.1 A2005001 2005-01-01 h18v04 2018145170156 1 5 #> 1.2 A2005001 2005-01-01 h18v04 2018145170156 2 5 #> 1.3 A2005001 2005-01-01 h18v04 2018145170156 3 5 #> 1.4 A2005001 2005-01-01 h18v04 2018145170156 4 5 #> 1.5 A2005001 2005-01-01 h18v04 2018145170156 5 5 #> 1.6 A2005001 2005-01-01 h18v04 2018145170156 6 5
# convert to raster LC_r <- mt_to_raster(df = LC)
#> Warning: Discarded ellps unknown in Proj4 definition: +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +R=6371007.181 +units=m +no_defs +type=crs
#> Warning: Discarded datum unknown in Proj4 definition
#> Warning: Discarded ellps unknown in Proj4 definition: +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +R=6371007.181 +units=m +no_defs +type=crs
#> Warning: Discarded datum unknown in Proj4 definition
# }