ModisDownload: Download, reproject, and mosaic Modis satellite images

ModisDownloadR Documentation

Download, reproject, and mosaic Modis satellite images


'ModisDownload' downloads a series of MODIS images in a specific date or a period of times, and for specified tile(s). It can also use MODIS Reproject Tool (MRT) software to mosaic the downloaded images, in case of selecting more than one tile, and reproject them to a specified coordinate system. As the format of the source images in LP DAAC is HDF, this tool can also convert them into other formats (i.e. Geotif, hdr).




ModisDownload(x,h,v,dates, ...)









character; username for authentication


character; password for authentication


logical; specifies whether .nerc file that has been previously created by setNASAauth, should be updated


product name or a number specifies the product row in the data.frame generated by modisProduct function. It can also be the http address of the product.


together with v specify the position of the Modis image tile(s). Examples: h=15; h=c(14,15); v=c(4:7)


see the above descriptopn for h


a character vector with the length of one or two, specifiying an individual date or a range of dates as the form of c(from, to)


the name of hdf file


coordinate reference system definiation (or a SpatRaster defines definition of new Raster for resampling)


integer vector specifies the layer number for subsetting bands


resample method for reprojection based on GDAL, can be one of "near","bilinear","cubic",or "cubicspline" (default: "near")


the names of hdf files


Path to the bin folder into the installed directory of MRT software. It is needed only if you need to mosaic and/or reproject the images. Example: MRTpath="d:/MRT/bin"


the name of new file


the product version. The default value is '006'


HDF-EOS input files contain several layers of data (bands). Through this argument you ca select a subset of bands. You need to know how many bands the product has, and which bands you want to be subset. Example: Suppose your image has 6 bands and you only need the second band. The parameter should be entered as: bands_subset="0 1 0 0 0 0".


Logical. If TRUE, the original HDF files will be deleted after mosaic or reproject into new files.


logical, specify whether the product should be re-downloaded if it had been downloaded before. The downloaded products are cashed using a hash digest of the inputs. If the download is canceled mid-way and the same exact products are downloaded again, it can be useful to avoid re-downloading them.


numerical; specify the number of cores used to speed up the download; 'auto' can be used instead to detect the number of cores and use half of them


The product name; can be extracted from the modisProduct function


additional arguments including:

- mosaic: logical, if TRUE, the images (several tiles) are mosaic into a single image

- proj: Logical. If TRUE, it means that you want to reproject the images. Then reprojectHDF function will be called to reproject the images.

- UL: Optional. Upper Left coordinate (x,y) in output coordinate system. Only if you want to spatially subset your images.

- LR: Optional. Lower right coordinate(x,y). Only if you want to spatially subset your images.

- resample_type: Resampling kernel type for MRT ("CUBIC_CONVOLUTION", "NEAREST_NEIGHBOR", or "BILINEAR"). The default is "NEAREST_NEIGHBOR".

- proj_type: Output projection short name. Valid values are "AEA" (Albers EqualArea), "ER" (Equirectangular), "GEO" (Geographic), "IGH" (Interrupted Goode Homolosine), "HAM" (Hammer), "ISIN" (Integerized Sinusoidal), "LA" (Lambert Azimuthal Equal Area), "LCC" (Lambert Conformal Conic), "MERCAT" (Mercator), "MOL" (Molleweide), "PS" (Polar Stereographic), "SIN" (Sinusoidal), "TM" (Transverse Mercator), and "UTM" (Universal Transverse Mercator).

- proj_params: Output projection parameters. This quoted, floating-point list includes up to 15 projection parameters, with each value separated by white space ("p1 p2 ... p15"). If there are fewer than 15 values specified in the list, the remaining values will be set to zero. Integer values will automatically be converted to floating point (See the MRT software manual for the details).

- datum: Specifies the output projection datum. The default is "WGS84"

- utm_zone: Valid only if "UTM" is selected for the proj_type.

- pixel_size: Output pixel size.


To be able to download the data, you need to register on "" and get a username and password. To pass the authentication by the website, you need to set the username and password on the machine (only first time) using setNASAauth function. Just specify the username and password in the function for the first time, and then the ModisDownload function can use it everytime you need to download the data.

To have the functionality for Mosaic and reprojecting of the images, you need to first install MRT software on your machine, and introduce its' path through the MRTpath argument. Otherwise, it can only be used for automating the downloading procedure.

The functions ModisDownload uses the functions including getMODIS, mosaicHDF (if needed), and reprojectHDF (if needed). The functions getMODIS, can be used to download HDF files, while mosaicHDF and reprojectHDF can mosaic and reproject the HDF files, respectively.


Babak Naimi & Pablo Alfaro


## Not run: 


# First, you need to register on and get a username and password
# for the first time, set the authentication info:


# product list:

modisProducts(version=NULL) # both versions

#x=3 # or x="MOD14A1"

# download 4 tiles (h14v04, h14v05, h15v04, h15v05) in single date (2011.05.01)

# Following command only downloads the source HDF images, no mosaic and no projection


# alternatively, you can use getMODIS to download only HDF images:


# same as the above command, but downloads all available images in 2011:



# Downloads selected tiles, and mosaic them, but no projections:


#--- alternatively, you can first download the HDF images using getMODIS, 
#and then mosaic them using mosaicHDF!

# Downloads selected tiles, and mosaic, reproject them in UTM_WGS84, zone 30 projection and 
#convert all bands into Geotif format (the original HDF will be deleted!):


# Same as above command, but only second band out of 6 bands will be kept. (You do not need 
#to specify proj_params when "UTM" is selected as proj_type and the zone also is specified,
#but for other types of projections you do).

              mosaic=T,proj=T, bands_subset="0 1 0 0 0 0", proj_type="UTM",
              proj_params="-3 0 0 0 0 0 0 0 0 0 0 0 0 0 0",utm_zone=30,

# Same as above command, but it spatially subsets the images into the specified box (UL and LR):

             bands_subset="0 1 0 0 0 0", proj_type="UTM",
             proj_params="-3 0 0 0 0 0 0 0 0 0 0 0 0 0 0",utm_zone=30,datum="WGS84",

## End(Not run)

rts documentation built on Sept. 17, 2022, 1:06 a.m.

Related to ModisDownload in rts...