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.

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?
    – Spacedman
    May 8 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
    May 8 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
    May 9 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
    – radfael
    May 10 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.