write_MRTSwath_param_file_mod02nrt {proccalibrad}R Documentation

Write a parameter control file for MRTSwath

Description

MRTSwath is the "MODIS Reprojection Tool for swath products". See: https://lpdaac.usgs.gov/tools/modis_reprojection_tool_swath).

Usage

write_MRTSwath_param_file_mod02nrt(prmfn = "tmpMRTparams.prm", tifsdir, modfn,
  geoloc_fn, ul_lon, ul_lat, lr_lon, lr_lat)

Arguments

prmfn

The name of the parameter/control file which will be the input to MRTSwath's swath2grid function.

tifsdir

The directory to save the output TIF files in

modfn

The filename of the MODIS data

geoloc_fn

The filename of the corresponding geolocation file (annoyingly, this is a much larger file than the data file!)

ul_lon

Upper left (ul) longitude (x-coordinate) for subsetting

ul_lat

Upper left (ul) latitude (y-coordinate) for subsetting

lr_lon

Lower right (lr) longitude (x-coordinate) for subsetting

lr_lat

Lower right (lr) latitude (y-coordinate) for subsetting

Details

If you want this function to use MRTSwath tool successfully, you should add the directory with the MRTSwath executable to the default R PATH by editing ~/.Rprofile.

This function hard-codes these options into the parameter file:
* all the bands are extracted
* the output file is a GeoTIFF
* the output projection is Geographic (plain unprojected Latitude/Longitude)
* the resampling is Nearest Neighbor (NN), which of course is the only one which makes sense when the pixels encode bytes that encode bits that encode discrete classification results, 0/1 error flags, etc.

MRTswath can do many other projections and output formats; users can modify this function to run those options.

Value

prmfn The name of the temporary parameter file

Author(s)

Rishabh Gupta rishabh.uk@gmail.com

See Also

run_swath2grid_mod02nrt

http://landweb.nascom.nasa.gov/cgi-bin/QA_WWW/newPage.cgi?fileName=hdf_filename @cite NASA2001

Examples


# Source MODIS files (both data and geolocation)
# Code excluded from CRAN check because it depends on modiscdata
## Not run: 
library(devtools)
library(modiscdata)
moddir = system.file("extdata/2002raw/", package="modiscdata")

# Get the matching data/geolocation file pairs
fns_df = check_for_matching_geolocation_files_mod02nrt(moddir, modtxt="MOD02", geoloctxt="MOD03")
fns_df

# Resulting TIF files go in this directory
tifsdir = getwd()


# Box to subset
ul_lat = 13
ul_lon = -87
lr_lat = 8
lr_lon = -82

for (i in 1:nrow(fns_df))
	{

	prmfn = write_MRTSwath_param_file_mod02nrt(prmfn="tmpMRTparams.prm", tifsdir=tifsdir,
	 modfn=fns_df$mod02_fns[i], geoloc_fn=fns_df$mod03_fns[i], ul_lon=ul_lon, ul_lat=ul_lat,
	  lr_lon=lr_lon, lr_lat=lr_lat)
	print(scan(file=prmfn, what="character", sep="\n"))

	}

## End(Not run)


[Package proccalibrad version 0.14 Index]