Configuring R with GRASS GIS - windows

I just started using GRASS GIS 7.0.0beta2. I want to use R in GRASS and vise versa. Following the instructions from here, when I bring the WinGRASS-windows console in front and type R for opening a R-session (command line mode) inside a GRASS-session, I get the following error:
sh.exe": R: command not found
How can I configure R and GRASS so that I can use R in GRASS and GRASS in R. I'm on Windows 7 with R 3.1.0 and GRASS GIS 7.0.0beta2.

I'm a Linux user, so I can't try it, but it seems to me that R bins directory is not in your PATH.
To test it, open a command line (should be cmd.exe) and try
R
If the output is the same as above, then add R bin directory to PATH, so you can call R from whatever directory you want.
Check one of the following links and apply it to the directory where R bins reside.
HTH, let me know. Luca

Related

USDZ File Not Loading on iPhone 7

Our USDZ file won't load on iPhone 7 with iOS 12. It works fine on my iPhone X and iPad Pro, both running iOS 12 Beta.
We've tried creating this using the terminal commands and get the following warning although we don't believe this is the issue.
Warning: in CreateMaterialBindings at line 59 of /BuildRoot/Library/Caches/com.apple.xbs/Sources/3DAssetTools/3DAssetTools-14207.2/external/ModelKit/extern/usd/pxr/usd/usdObj/translator.cpp -- OBJ mtl usemtl name has invalid name '15___Default', using default usemtl name: 'defaultShadeGroup0'
The screen on the iPhone 7 looks as such:
You can download the raw files here.
You can't see your 3D model because you're using very bad naming convention for file model2_$$usd_converter$$_.usdc inside usdz container. In macOS and iOS you have to avoid using $ in file names, because dollar sign is a special character.
Follow these two steps to unzip, rename and rezip your usdz file.
First Step (unzip mmtest.usdz file)
To unzip a usdz file in macOS Mojave use the following method:
In Finder change the extension of .usdz file to .zip.
Uncompress .zip file using Archive_Utility.app or RAR_Extractor.app.
Open unzipped directory and change files' names.
Make sure all textures are in JPG and/or PNG format.
Make sure 3D normals of your USDC model ain't inverted.
Second Step (recreate usdz again)
Make sure that Xcode 10.2 is installed.
To convert a content of unzipped folder (binary usdc file and its textures) to usdz file format again, use the following command in Terminal.app:
cd ~/Desktop/mmtest/
xcrun usdz_converter Model.usdc Model.usdz
-g SofaMesh
-color_map Diffuse.jpg
-roughness_map Roughness.png
-normal_map Normal.jpg
And here are a full list of options (type xcrun usdz_converter -h in Terminal):
-g groupName [groupNames ...] Apply subsequent material properties to the named group(s).
-m materialName [materialNames ...] Apply subsequent material properties to the named material(s).
-h Display help.
-a Generate a .usda intermediate file. Default is .usdc.
-l Leave the intermediate .usd file in the source folder.
-v Verbose output.
-f filePath Read commands from a file.
-texCoordSet set The name of the texturemap coordinate set to use if multiple exist (no quotes).
-opacity o Floating point value 0.0...1.0
-color_default r g b a Floating point values 0.0...1.0
-normal_default r g b a Floating point values 0.0...1.0
-emissive_default r g b a Floating point values 0.0...1.0
-metallic_default r g b a Floating point values 0.0...1.0
-roughness_default r g b a Floating point values 0.0...1.0
-ao_default r g b a Floating point values 0.0...1.0
-color_map filePath
-normal_map filePath
-emissive_map filePath
-metallic_map filePath
-roughness_map filePath
-ao_map filePath
Now model works perfectly.

How to set Crtrl+r to execute commands in Rstudio

How can I set RStudio to use Ctrl+R (in addition to Ctrl+Enter) to execute commands?
https://community.rstudio.com/t/bring-ctrl-r-back/1846 suggests editing the "rstudio_bindings.json" file, but I can't find the file.
https://support.rstudio.com/hc/en-us/articles/206382178-Customizing-Keyboard-Shortcuts gives instructions to add using from the menu options. I tried to add "Ctrl+Enter|Ctrl+R" as suggested in the first link but this is not accepted. At the bottom of the page it describes how the bindings are saved at ~/.R/rstudio/keybindings/rstudio_commands.json or ~/.R/rstudio/keybindings/editor_commands.json. I cannot find either of these files.
How can I do this?
R version 3.4.2
RStudio Version 1.1.383
Windows 7
Following advice from https://community.rstudio.com/t/bring-ctrl-r-back/1846,
you have to edit the file ~/.R/rstudio/keybindings/rstudio_bindings.json with
{
"executeCode" : "Ctrl+Enter|Ctrl+R"
}
These directories and file already existed on Ubuntu, however, neither the file nor any of the directories existed on my Windows partition. So needed to create the nested directories .R/rstudio/keybindings, and then create the json file shown above, and save it as rstudio_bindings.json.
(aside: Windows didn't like trying to name a new folder of .R (the leading dot gave problems), but you can get round this by naming .R. , as the trailing dot is removed from here )

Accessing files within a parent folder and it's sub-folders using Python

I have a folder which has subfolders containing 1000s of DICOM images which I want to read in from IDLE and analyze.
I have used the following code to find file paths:
import sys
print sys.path
I subsequently tried placing my folder which I want to access in these file paths, however I still can not access the files and I get the following error:
>>> fp = open(fp, 'rb')
IOError: [Errno 2] No such file or directory: 'IM-0268-0001.dcm'
I have also tried:
sys.path.insert(0, 'C:/desktop/James_Phantom_CT_Dec_16th/Images')
But this did not work for me either. Help much appreciated, very frustrated.
(using Python 2.7, 64 bit windows OS).
When opening a file, Python does not search the path. You must specify the full path to open:
d = 'C:/desktop/James_Phantom_CT_Dec_16th/Images'
fp = open(d +'IM-0268-0001.dcm',"rb")
Edit: d is the string that will hold the path so that you don't have to re-type it for each file. fp will hold the file object that you will work with. The "rb" is the way you want to open the file:
r - read
w - write with truncate
a - append
r+ - read and write
Also, if working in windows, add "b" to work with binary files. See here.

open file with shell() in R

I want to open a file in a windows program using R, but specifying the program rather than the default for the file extension, and for a file not necesarrily in my current R session home directory (this one getwd())
From looking at the documentation, using shell(), should be the way, but I seem to have an issue with the way R references the home directory or the way I'm writing the string.
e.g.
This works ok in the cmd "run" in windows: excel e:\test.xlsx
but using this
route <- "e:\\test.xlsx"
shell(paste("excel " , route, sep=""), flag="")
seems to get to excel (excel copyright notice is printed), but also prints the home directory and doesn't open the file in route. Thanks for any help.
Your command does the same for me. However, this works:
shell(paste("start", "excel", route))

Loading a DOT file using RGL

RGL supports writing DOT files from a graph, is it possible to create a graph from a DOT file?
(Obviously I can parse the DOT file myself and create a graph, but I'm wondering if this functionality exists already).
First you have to install graphviz which gives you the 'dot' command.
Then you can run
dot -Tpng graph.dot > output.png
but I found that after installing dot the rgl method write_to_graphic_file automatically writes the image if you do something like
graph_obj.write_to_graphic_file('png')

Resources