I want to select a certain field (X) from an input vector layer in my R processing script. In the below example, I want to be able to select the field (X) from the input (Layer). But the actual model always shows the fields (X) of the first (alphabetical) point layer in my QGIS project. It should reactively update the field drop down list according to which layer I selected.
##showplots
##Layer=vector point
##X=Field Layer
boxplot(Layer[[X]])
The user interface of the model. I want X to be updated according to which layer I select.
-
Is this just the way QGIS works? It always gives a list of the layers, and you want it to pre-select the current QGIS selected layer? That would require some changes to the QGIS processing system - have you checked the QGIS tracker to see if anyone has suggested this already? Or add a new request there?Spacedman– Spacedman2023年05月08日 12:56:06 +00:00Commented May 8, 2023 at 12:56
-
@Spacedman I think we are talking about different things: I want to select a certain field of the input layer. This works fine in many of the standart QGIS tools. I think the issue is that I haven't understood how R processing in QGIS works... if I click run (in my coded scripts) nothing happens, although if I run the standard R pre-installed scripts (from the plugin) they run fine.radfael– radfael2023年05月08日 21:40:39 +00:00Commented May 8, 2023 at 21:40
-
Ah okay. This works for me. My first layer has columns A and B, my second has C and D. Running the script originally shows me the first layer with an empty X, which drops down A and B. If I change to the second layer I see C and D on the drop down. What version of QGIS and R Processing Plugin are you using? QGIS: 3.26.3-Buenos Aires and processing_r: 3.1.1 here (see Help... About... for versions)Spacedman– Spacedman2023年05月09日 11:09:59 +00:00Commented May 9, 2023 at 11:09
-
After I did the same test as you it still didn't work. I thought it must be some underlying problem. I found this post gis.stackexchange.com/questions/112061/accessing-r-from-qgis and reinstalled R on my C drive. This worked!! Thanks for your helpradfael– radfael2023年05月10日 03:26:17 +00:00Commented May 10, 2023 at 3:26
1 Answer 1
R needs to be installed in a folder with writing rights (Windows). Accessing R from QGIS?
This solved the problem and all R scripts worked.