I am trying to figure out how to use INLA without any formal instruction and I have visited the INLA website (www.r-inla.org) to view some examples. I have also been reading through the book Spatial and Spatio-temporal Bayesian Models with R - INLA 1st Edition by Marta Blangiardo and Michela Cameletti. My trouble is that my questions are just too simple to get answers there and the INLA package seems too new to have thorough discussions on any programming forums that I can find. I should also mention I am new to mapping in R.

I have seen some examples of using the MODISTools package to download subsets of data but it seems like this will download the requested data only at the point locations I specify using the lat and lon arguments of the MODISSubset command. For the intended analysis, I will need the data available over a shape that spans a couple different tiles. Is there a way to use a shapefile to specify the data that I would like to download in MODISTools? The vignette didn't allude to this but maybe I misunderstood something.

Specifically, I am looking to download as much available data from the MOD13A2, MOD44W and MOD11A2 data sets as possible from the years 2011-2015. I need this for a shapefile that would fit into a box with an upper left corner of (lat:13.891715, lon:34.957847) and a lower right corner of (lat:8.670194, lon:40.308822) which is Eastern Africa.

  • You may have a look at the MODIStsp package. It should do what you need.
    – lbusett
    May 16, 2017 at 18:28
  • What MODIS data in particular are you looking for? Methods to get the correct data can vary by product and region.
    – GISHuman
    May 16, 2017 at 18:42
  • You are asking multiple questions, with one that is vague and quite expansive to answer. Please edit your post to identify a single question with a clear objective. May 16, 2017 at 18:42
  • My appologies. edited
    – Andrew N
    May 16, 2017 at 19:29
  • as stated above, the MODIStsp package allows automatic downloading, preprocessing and resize/mosaicing of all MODIS Land Products. If can provide a shapefile as one of the inputs, output rasters are automatically "cropped" on its extent. See cran.r-project.org/web/packages/MODIStsp/vignettes/MODIStsp.pdf
    – lbusett
    May 17, 2017 at 9:21

1 Answer 1


I have used the MODIS package for this task before. Here is a sketch of the process (download, reproject, stitch):


# Set MODIS options: data directories, projection, resolution, etc.
dir.create(file.path("path", "to", "modis", "raw"), showWarnings = FALSE)
dir.create(file.path("path", "to", "modis", "processed"), showWarnings = FALSE)

  localArcPath = file.path("path", "to", "modis", "raw"),
  outDirPath = file.path("path", "to", "modis", "processed"),
  outProj = "+proj=longlat +datum=WGS84 +ellps=WGS84",
  pixelSize = 1,
  dlmethod = "wget"

# Downloading data requires authentication and registration at https://urs.earthdata.nasa.gov/home
# Run the following command once to generate a .netrc file for EarthData (LPDAAC) login credentials
MODIS::lpdaacLogin(server = "LPDAAC")

# Download and process (stitch, reproject, dis / aggregate) 
  product = "MOD(13A2|44W|11A2)", 
  begin = "2011-01-01",
  end = "2015-12-31",
  extent = list(xmin = 34.957847, xmax = 40.308822, ymin = 8.670194, ymax = 13.891715)

# list stitched MODIS products
modis.fp <- list.files(
  path = file.path("path", "to", "modis", "processed"),
  pattern = "tif$",
  recursive = TRUE,
  full.names = TRUE

# loading the first processed raster for demonstration
r <- raster::raster(x = modis.fp[1])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.