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]]
Hi John: When El Capitan first came out there was a discussion in the R-SIg-Mac list about environmental variables not being passed down to applications (not just R abut in general). I believe a work around was suggested, but I would search the archives for that. So what is happening, when you run from the command line, the variables MRT_DATA_DIR and MRTDATADIR which are defined somewhere in your environment are found in the terminal, but when the same command is run from the application they are not being found. I would search the R-SIg-Mac archive or post to that list, because i can?t remember what the work around was for it. HTH, -Roy> On Jun 4, 2016, at 11:59 AM, J Payne <jcpayne at uw.edu> wrote: > > 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]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.********************** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ********************** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new address and phone*** 110 Shaffer Road Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.
> On 4 Jun 2016, at 22:12, Roy Mendelssohn - NOAA Federal <roy.mendelssohn at noaa.gov> wrote: > > Hi John: > > When El Capitan first came out there was a discussion in the R-SIg-Mac list about environmental variables not being passed down to applications (not just R abut in general). I believe a work around was suggested, but I would search the archives for that. > > So what is happening, when you run from the command line, the variables MRT_DATA_DIR and MRTDATADIR which are defined somewhere in your environment are found in the terminal, but when the same command is run from the application they are not being found. I would search the R-SIg-Mac archive or post to that list, because i can?t remember what the work around was for it. >I can't find the discussion on R-SIG-Mac list. But you can try this: MRT_DATA_DIR=<whatever> open -a Rstudio or MRT_DATA_DIR=<whatever> open -a R Try it and see what happens. It may even be possible to put something in .Rprofile setting your environment variables. Berend Hasselman> HTH, > > -Roy > >> On Jun 4, 2016, at 11:59 AM, J Payne <jcpayne at uw.edu> wrote: >> >> 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]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > ********************** > "The contents of this message do not reflect any position of the U.S. Government or NOAA." > ********************** > Roy Mendelssohn > Supervisory Operations Research Analyst > NOAA/NMFS > Environmental Research Division > Southwest Fisheries Science Center > ***Note new address and phone*** > 110 Shaffer Road > Santa Cruz, CA 95060 > Phone: (831)-420-3666 > Fax: (831) 420-3980 > e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/ > > "Old age and treachery will overcome youth and skill." > "From those who have been given much, much will be expected" > "the arc of the moral universe is long, but it bends toward justice" -MLK Jr. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Thanks very much Roy! I will post to R-Sig-Mac. I browsed their archives but didn?t see anything about the issue ? I might have missed something, though. John On 6/4/16, 1:12 PM, "Roy Mendelssohn - NOAA Federal" <roy.mendelssohn at noaa.gov> wrote:>Hi John: > >When El Capitan first came out there was a discussion in the R-SIg-Mac list about environmental variables not being passed down to applications (not just R abut in general). I believe a work around was suggested, but I would search the archives for that. > >So what is happening, when you run from the command line, the variables MRT_DATA_DIR and MRTDATADIR which are defined somewhere in your environment are found in the terminal, but when the same command is run from the application they are not being found. I would search the R-SIg-Mac archive or post to that list, because i can?t remember what the work around was for it. > >HTH, > >-Roy > >> On Jun 4, 2016, at 11:59 AM, J Payne <jcpayne at uw.edu> wrote: >> >> 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]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > >********************** >"The contents of this message do not reflect any position of the U.S. Government or NOAA." >********************** >Roy Mendelssohn >Supervisory Operations Research Analyst >NOAA/NMFS >Environmental Research Division >Southwest Fisheries Science Center >***Note new address and phone*** >110 Shaffer Road >Santa Cruz, CA 95060 >Phone: (831)-420-3666 >Fax: (831) 420-3980 >e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/ > >"Old age and treachery will overcome youth and skill." >"From those who have been given much, much will be expected" >"the arc of the moral universe is long, but it bends toward justice" -MLK Jr. >