[R] system() command not working
J Payne
jcpayne at uw.edu
Sat Jun 4 20:59:16 CEST 2016
I’ve posted this question on StackExchange at http://stackoverflow.com/questions/37604466/r-system-not-working-with-modis-reprojection-tool, but haven’t received any replies. I’m hoping that someone who understands the operation of the R system() command can help.
I have a command that works when typed into the Terminal on a Mac (OSX El Cap), but exactly the same command fails when called from R using `system()`.
I am trying to batch-process MODIS satellite files using a small program called the MODIS Reprojection Tool (https://lpdaac.usgs.gov/tools/modis_reprojection_tool). My software is all up to date.
This is a simple example in which I mosaic two files. The names of the two files are in a text input file called `input.list`. The command just tells the `mrtmosaic` routine where to find the input list and where to put the output.
This command works correctly in the Terminal:
/Applications/Modis_Reprojection_Tool/bin/mrtmosaic -i ~/temp/input.list -o ~/temp/output.hdf
However, if I put exactly the same string into a variable and run it from R (using RStudio), it fails:
comstring<-"/Applications/Modis_Reprojection_Tool/bin/mrtmosaic -i ~/temp/input.list -o ~/temp/output.hdf"
system(comstring)
>Warning: gctp_call : Environmental Variable Not Found:
MRT_DATA_DIR nor MRTDATADIR not defined
Error: GetInputGeoCornerMosaic : General Processing Error converting lat/long coordinates to input projection coordinates.
Fatal Error, Terminating...
The strange thing is that the system knows what the environment variables are. In the terminal, the command
`echo $MRT_DATA_DIR`
shows the correct directory: /Applications/Modis_Reprojection_Tool/data
I don't see why it would have trouble finding the variables from an `R system()` call when it has no trouble in the Terminal. I'm very stumped!
[[alternative HTML version deleted]]
More information about the R-help
mailing list