How to extract data from a MODIS HDF file?

How to extract data from a MODIS HDF file?

To download extract data from a MODIS HDF file in R you need a few packages. Mainly: After installing these packages make sure you load them to continue. First you have to determine where your data is located within the tiled format MODIS data is distributed in.

How is data stored in a HDF file?

As previously mentioned, data is stored in HDF files. These files are readily readable by the GDAL library. However, given the structured nature of these files you have to know what you are looking for. These layers in structured HDF files are called scientific data sets (SDS).

What kind of data does the MODIS sensor collect?

The Moderate-resolution imaging spectroradiometer (MODIS) sensors on both Aqua and Terra platforms provide a wealth of (environmental) data. However, manipulating the raw files can be challenging.

How is the location of Harvard Yard calculated in MODIS?

All MODIS data are distributed in a custom sinusoidal projection, hence the rather weird looking shape of the map. In order to find the right tile we load a coordinate into R. In this case it’s the location of Harvard Yard, or 42.375028, -71.116493 latitude and longitude respectively.

Can you read a.tif file into R?

Now you can read your .tif files into R using, for example, raster from the raster package and work as normal. I’ve checked the resulting files against a few I converted manually using QGIS and they match so I’m confident the code is doing what I think it is.

How to read MODIS 17 data files into R?

I’m trying to read MODIS 17 data files into R, manipulate them (cropping etc.) and then save them as geoTIFF’s. The data files come in .hdf format and there doesn’t seem to be an easy way to read them into R. Compared to other topics there isn’t a lot of advice out there and most of it is several years old.

How to convert HDF4 files to GeoTIFFs in R?

Basically gdal_translate from the gdalUtils package is the saving grace for anyone who wants to use hdf4 files in R. It converts hdf4 files into geoTIFFs without reading them into R.