0

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.

asked May 8, 2023 at 8:27
4
  • 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? Commented 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. Commented 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) Commented 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 help Commented May 10, 2023 at 3:26

1 Answer 1

0

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.

answered May 10, 2023 at 3:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.