IS there a way to get MODIS tiles as a function of lat/long in R?

Geoff Source

I'm looking for a way to automatically return the MODIS tile (e.g. h12 v4) as a function of longitude and latitude.

I was hoping the MODIS package could do it using getTile(***). I see there's a nice GUI when I use getTile() but I'm looking for an automatic method as a function of long/lat.

thanks, Geoff

rcoordinatestiler-modis

Answers

answered 1 month ago fdetsch #1

A good suggestion! This is currently included in the MODIS 'develop' branch, and it will definitely be part of future package versions (starting with 1.1.4). Until the next CRAN release, simply install the current 'develop' version from GitHub and see if this works for you:

# devtools::install_github("MatMatt/MODIS", ref = "develop")
library(MODIS)

## set point coordinates (taken from https://en.wikipedia.org/wiki/Frankfurt)
dat = data.frame(lon = 8.682222, lat = 50.110556, loc = "Frankfurt am Main")
pts = sf::st_as_sf(dat, coords = c("lon", "lat"), crs = 4326)

## get overlying tile
tls = getTile(pts)
[email protected]
# [1] "h18v03"

One important caveat, though: at the moment, this only works with sp (ie. Spatial*) and sf point inputs.

comments powered by Disqus