Title: | Tools for Satellite Remote Sensing (Earth Observation) Data Processing |
---|---|
Description: | Tools for acquiring and (pre-) processing satellite remote sensing data. Including for downloading data from NASA such as LANDSAT and MODIS. |
Authors: | Robert J. Hijmans [cre, aut] , Aniruddha Ghosh [aut], Alex Mandel [ctb], Benson Kenduiywo [ctb], Jakob Schwalb-Willmann [ctb] |
Maintainer: | Robert J. Hijmans <[email protected]> |
License: | GPL (>=3) |
Version: | 0.3-6 |
Built: | 2024-10-31 04:49:58 UTC |
Source: | https://github.com/rspatial/luna |
Tools for acquiring and (pre-) processing satellite remote sensing data. Including for downloading data from NASA such as LANDSAT and MODIS.
Estimate missing values using smooth gap-filled time series data with a two-stage Savitzky-Golay smoothing filter.
filterVI(x, ...) fillVI(x, method = "natural")
filterVI(x, ...) fillVI(x, method = "natural")
x |
numeric or SpatRaster representing time series signal to be filtered |
method |
type of spline to be used. Possible values are "fmm", "natural", "periodic", "monoH.FC" and "hyman" |
... |
additional arguments:
|
Performs smoothing of time series data using a two pass Savitzky-Golay smoothing filter. Second pass is an iterative method to minimize the difference between actual and fitted values that are significantly lower than the actual values. Missing values designated as NA
are automatically interpolated with spline
. For more details on the arguments see splinefun
and sgolayfilt
.
Filtered signal of length(x)
# apply on single pixel #vi <- .... #s <- filterVI(vi) # for time series raster #fevi <- app(evi, filterVI)
# apply on single pixel #vi <- .... #s <- filterVI(vi) # for time series raster #fevi <- app(evi, filterVI)
Find and download AVHRR NDVI CDR global layers for a time period. The function returned is list of filenames that may have been downloaded.
getAVHRR(start_date, end_date, path = "", overwrite=FALSE, update=FALSE, ...)
getAVHRR(start_date, end_date, path = "", overwrite=FALSE, update=FALSE, ...)
start_date |
character. Start date for the data requested formatted yyyy-m-d |
end_date |
Character. end date for the data requested formatted yyyy-m-d |
overwrite |
logical. If |
path |
character. Path name indicating where to store the data |
update |
logical. If |
... |
Additional arguments that can be passed to |
Downloads compressed global layers within the dates specified. For further processing, uncompressed ".nc4" files can be opened with the terra
package.
Character vector of file names pointing to the downloaded files
start <- "2019-05-17" end <- "2019-05-23" path <- tempdir() # ff <- getAVHRR(start, end, path)
start <- "2019-05-17" end <- "2019-05-23" path <- tempdir() # ff <- getAVHRR(start, end, path)
Download data provided by the Copernicus Global Land Service (https://land.copernicus.eu/global/) You need to register at https://land.copernicus.eu/global/ and create a username and password.
See https://land.copernicus.eu/global/products/ for a product overview and product details and see https://land.copernicus.vgt.vito.be/manifest/ for an overview for data availability.
getCGLS(product, start_date, end_date, resolution="1km", version=1, path, username, password, ...)
getCGLS(product, start_date, end_date, resolution="1km", version=1, path, username, password, ...)
product |
character. For example: "fapar", "fcover", "lai", "ndvi", "ssm", "swi", "lst" |
resolution |
character. one of "1km", "300m" or "100m" |
version |
positive integer. product version |
start_date |
character or Date. Start date for the data requested formatted yyyy-m-d |
end_date |
Character or Date. End date for the data requested formatted yyyy-m-d |
path |
character. Path name indicating where to store the data |
username |
character. EOSDIS user name (see Details) |
password |
character. EOSDIS password (see Details) |
... |
Additional arguments passed to download.file) |
SpatRaster
Find and download Earth Explorer data
getEE(product, ids, path, username, password, ...)
getEE(product, ids, path, username, password, ...)
product |
character. Supported products can be found using |
ids |
entity IDs |
path |
character. Path name indicating where to store the data |
username |
character. EOSDIS user name (see Details) |
password |
character. EOSDIS password (see Details) |
... |
Additional arguments. None implemented |
This function is an R interface to the Earth Explores system. Access is free, but it requires a "Earthdata" account. If you do not have an account, you can sign up here: https://urs.earthdata.nasa.gov/users/new
Character vector of file names pointing to the downloaded files
Find and download ERS data
getERS(scenes, path, username, password, overwrite=FALSE, ...)
getERS(scenes, path, username, password, overwrite=FALSE, ...)
scenes |
character |
path |
character. Path name indicating where to store the data |
username |
character. User name |
password |
character. Password |
overwrite |
logical. If |
... |
additional arguments. None implemented |
Character vector of file names pointing to the downloaded files
Find and download Landsat data for a specific product, area, and time period. The function returned is list of filenames that may have been downloaded.
getLandsat(product="Landsat_8_OLI_TIRS_C1", start_date, end_date, aoi, download=FALSE, path, username, password, version="1", limit=100000, server="AWS", overwrite=FALSE, ...)
getLandsat(product="Landsat_8_OLI_TIRS_C1", start_date, end_date, aoi, download=FALSE, path, username, password, version="1", limit=100000, server="AWS", overwrite=FALSE, ...)
product |
character. Supported products can be found using |
start_date |
character. Start date for the data requested formatted yyyy-m-d |
end_date |
character. end date for the data requested formatted yyyy-m-d |
aoi |
numeric vector of four elements (minimum longitude, maximum longitude, minimum latitude, maximum latitude) encompassing the area of interest. Or a SpatExtent or Extent object, or any object from which an Extent can be extracted (see examples) |
download |
logical. If |
path |
character. Path name indicating where to store the data |
username |
character. EROS user name (see Details) |
password |
character. EROS password (see Details) |
version |
character |
limit |
integer > 0 |
server |
character. Either AWS (Landsat 8 only) or ERS. See Details |
overwrite |
logical. If |
... |
Additional arguments. These can be product specific. See Details) |
The AWS (Amazon Web Services) server provides Landsat 8 data only. It does not require credentials (username and password).
The EROS service from the USGS also provides other Landsat products. To use for downloading data, you need to provide "ERS" credentials. If you do not have these, you can sign up for a free account here: https://ers.cr.usgs.gov/register
If no data is available between start_date
and end_date
, files for the closest dates are returned.
character vector of file names pointing to the downloaded files (if download=TRUE
)
product <- "Landsat_8_OLI_TIRS_C1" sdate <- "2019-05-01" edate <- "2019-05-30" area <- c(33, 34, -5, -4) dir <- tempdir() f <- getLandsat(product, start_date=sdate, end_date=edate, aoi=area, download=FALSE, path=dir) # An example of ARD Tiles from ERS server product <- "Landsat4-8_ARD_US_C1" area <- c(-122.43, -121.50, 38.32, 38.91) f1 <- getLandsat(product, start_date=sdate, end_date=edate, aoi=area, download=FALSE, path=dir, server="EROS")
product <- "Landsat_8_OLI_TIRS_C1" sdate <- "2019-05-01" edate <- "2019-05-30" area <- c(33, 34, -5, -4) dir <- tempdir() f <- getLandsat(product, start_date=sdate, end_date=edate, aoi=area, download=FALSE, path=dir) # An example of ARD Tiles from ERS server product <- "Landsat4-8_ARD_US_C1" area <- c(-122.43, -121.50, 38.32, 38.91) f1 <- getLandsat(product, start_date=sdate, end_date=edate, aoi=area, download=FALSE, path=dir, server="EROS")
Find and download NASA data for a specific product, area, and time period. The function returned is list of filenames that may have been downloaded.
It is important to fist consult getProducts
to discover what products and version numbers are available, and which server to use.
getNASA(product, start_date, end_date, aoi, version="006", download=FALSE, path, username, password, server="LPDAAC_ECS", limit=100000, overwrite=FALSE, ...)
getNASA(product, start_date, end_date, aoi, version="006", download=FALSE, path, username, password, server="LPDAAC_ECS", limit=100000, overwrite=FALSE, ...)
product |
character. Supported products can be found using |
start_date |
character. Start date for the data requested formatted yyyy-m-d |
end_date |
Character. end date for the data requested formatted yyyy-m-d |
aoi |
numeric vector of four elements (minimum longitude, maximum longitude, minimum latitude, maximum latitude) encompassing the area of interest. It can also be a SpatExtent, or any object from which an extent can be extracted |
version |
character. product version |
download |
logical. If |
path |
character. Path name indicating where to store the data |
username |
character. EOSDIS user name (see Details) |
password |
character. EOSDIS password (see Details) |
server |
character. The server to download the data from |
limit |
positive integer |
overwrite |
logical. If |
... |
Additional arguments. These can be product specific. See Details) |
This function is an R interface to the EOSDIS system. Access is free, but it requires a "Earthdata" account. If you do not have an account, you can sign up here: https://urs.earthdata.nasa.gov/users/new
If no data is available between start_date
and end_date
, files for the closest dates are returned.
Character vector of file names pointing to the downloaded files (if download=TRUE
)
product <- "MOD09A1" # information about the product getProducts(product) sdate <- "2019-05-17" edate <- "2019-05-23" area <- c(33, 34, -5, -4) path <- tempdir() # list available tiles f <- getNASA(product = product, start_date = sdate, end_date = edate, aoi = area, download = FALSE, path=path) f # get the date from the filenames modisDate(f) # to download the tiles, set download = TRUE # and provide your credentials usr <- "your user name" pwd <- "your password" #f <- getNASA(product = product, username=urs, password=pwd, # start_date = sdate, end_date = edate, # aoi = area, download = TRUE, path=path)
product <- "MOD09A1" # information about the product getProducts(product) sdate <- "2019-05-17" edate <- "2019-05-23" area <- c(33, 34, -5, -4) path <- tempdir() # list available tiles f <- getNASA(product = product, start_date = sdate, end_date = edate, aoi = area, download = FALSE, path=path) f # get the date from the filenames modisDate(f) # to download the tiles, set download = TRUE # and provide your credentials usr <- "your user name" pwd <- "your password" #f <- getNASA(product = product, username=urs, password=pwd, # start_date = sdate, end_date = edate, # aoi = area, download = TRUE, path=path)
Find available products in NASA's Common Metadata Repository (CMR) that can be downloaded. See getNASA
for further use.
getProducts(product, ...)
getProducts(product, ...)
product |
character |
... |
additional arguments. None implemented |
character
# list of all available MODIS products getProducts("^MOD|^MYD|^MCD")
# list of all available MODIS products getProducts("^MOD|^MYD|^MCD")
mesma
performs a multiple endmember spectral mixture analysis on a multiband raster image.
For unmixing, a non-negative least squares (NNLS) regression which is using a sequential coordinate-wise algorithm (SCA) based on Franc et al. (2005).
## S4 method for signature 'SpatRaster' mesma(x, em, iterate=400, tolerance=0.00000001, ...)
## S4 method for signature 'SpatRaster' mesma(x, em, iterate=400, tolerance=0.00000001, ...)
x |
SpatRaster. Usually representing a hyperspectral remotely sensed image |
em |
matrix or data.frame with spectral endmembers. Rows represent a single endmember of a class, columns represent the spectral bands (i.e. columns correspond to number of bands in |
iterate |
integer. Set maximum iteration per pixel. Processing time could increase the more iterations are made possible |
tolerance |
numeric. Tolerance limit representing a nearly zero minimal number |
... |
further arguments passed to writeRaster |
SpatRaster with one layer per end-member, with each value representing the estimated presence probability of the end-member per pixel (0 to 1), and an RMSE layer.
Depending on iterate
and tolerance
settings, the sum of estimated presence probabilities per pixel varies around 1.
Jakob Schwalb-Willmann
Franc, V., Hlaváč, V., & Navara, M. (2005). Sequential coordinate-wise algorithm for the non-negative least squares problem. In: International Conference on Computer Analysis of Images and Patterns (pp. 407-414). Berlin, Heidelberg.
lsat <- rast(system.file("ex/lsat.tif", package="luna")) # endmember spectra: water and land em_names <- c("water", "land") pts <- data.frame(class=em_names, cell = c(47916,5294)) em <- lsat[pts$cell] rownames(em) <- em_names # unmix the image for water and land probs <- mesma(lsat, em) # take a look hist(probs$water) plot(probs$water, col = c("white","blue")) hist(probs$land) plot(probs$land, col = c("white","brown"))
lsat <- rast(system.file("ex/lsat.tif", package="luna")) # endmember spectra: water and land em_names <- c("water", "land") pts <- data.frame(class=em_names, cell = c(47916,5294)) em <- lsat[pts$cell] rownames(em) <- em_names # unmix the image for water and land probs <- mesma(lsat, em) # take a look hist(probs$water) plot(probs$water, col = c("white","blue")) hist(probs$land) plot(probs$land, col = c("white","brown"))
Create a "mask" for a MODIS image based your selection of bad quality pixels, using the Quality Assessment (QA) band.
modis_mask(x, bits, qmat, ...)
modis_mask(x, bits, qmat, ...)
x |
SpatRaster |
bits |
single integer value: 16 or 32 |
qmat |
three-column matrix of data.frame. The first and second columns are positive integers (or character representation thereof) indicating the start and end bits (starting counting at one, not at zero!). The third column has the patterns to be rejected, stored as comma-separated characters. See example |
... |
additional arguments, none implemented |
SpatRaster
## Not run: f <- "MOD09A1.A2011009.h21v08.006.2015216112834.hdf" mod <- rast(f) shortnames <- substr(names(mod), 86, 120) names(mod) <- shortnames qc <- mod[[12]] from <- c(1,3,11,12) #,16) to <- c(2,6,11,14) #,17) reject <- c("10,11", "1100,1101,1110,1111", "1", "000,110,111") # "11") qmat <- cbind(from, to, reject) m <- modis_mask(qc, 16, qmat) plot(m) ## End(Not run)
## Not run: f <- "MOD09A1.A2011009.h21v08.006.2015216112834.hdf" mod <- rast(f) shortnames <- substr(names(mod), 86, 120) names(mod) <- shortnames qc <- mod[[12]] from <- c(1,3,11,12) #,16) to <- c(2,6,11,14) #,17) reject <- c("10,11", "1100,1101,1110,1111", "1", "000,110,111") # "11") qmat <- cbind(from, to, reject) m <- modis_mask(qc, 16, qmat) plot(m) ## End(Not run)
Extract the date that is encoded in a MODIS filename
modisDate(filename)
modisDate(filename)
filename |
character. MODIS product filenames |
data.frame
modisDate("MOD09A1.A2019137.h21v09.006.2019150085736.hdf")
modisDate("MOD09A1.A2019137.h21v09.006.2019150085736.hdf")
Get the extent of a MODIS tile from the h (horizontal; column number) and v (vertical; row number) identifier in the filename
modisExtent(f=NULL, h, v)
modisExtent(f=NULL, h, v)
f |
character. filename that includes a h12v09 pattern |
h |
integer between 0 and 35 |
v |
integer between 0 and 17 |
SpatExtent
f <- "MOD09A1.A2019137.h21v09.006.2019150085736.hdf" modisExtent(f) modisExtent(h=21, v=9)
f <- "MOD09A1.A2019137.h21v09.006.2019150085736.hdf" modisExtent(f) modisExtent(h=21, v=9)
Panchromatic band sharpening of lower resolution satellite images.
## S4 method for signature 'SpatRaster,SpatRaster' panSharpen(x, p, method="Brovey", weights=NULL, filename="", overwrite=FALSE, ...)
## S4 method for signature 'SpatRaster,SpatRaster' panSharpen(x, p, method="Brovey", weights=NULL, filename="", overwrite=FALSE, ...)
x |
SpatRaster with layers (bands) to be sharpened |
p |
SpatRaster with a single panchromatic layer at a higher spatial resolution than |
method |
character. Either "Brovey" or "HSI" |
weights |
optional vector of weights for the "Brovey" method. The weights should have a length equal to |
filename |
character. Output filename |
overwrite |
logical. If |
... |
additional arguments for writing files as in |
SpatRaster
Get complete product information in the corresponding product website. The information is displayed in the default browser. See getProducts
for available options of products.
productInfo(product, ...)
productInfo(product, ...)
product |
character |
... |
additional arguments (non implemented |
## Not run: # MODIS in LP DAAC with version information productInfo(product = "MCD18A1") # Without any version or server information productInfo(product = "LANDSAT_SURFACE_REFLECTANCE_L8_OLI_TIRS") ## End(Not run)
## Not run: # MODIS in LP DAAC with version information productInfo(product = "MCD18A1") # Without any version or server information productInfo(product = "LANDSAT_SURFACE_REFLECTANCE_L8_OLI_TIRS") ## End(Not run)