Use the corrected script Bug report #14608: Processing: Kriging rscripts/Kriging.rsx Automap problem and correction, accepted in the master (Kriging.rsx)
It is not a problem of QGIS, it is a problem with you R packages installation.
1) Processing use the Python subprocess module to execute directly the R commands
2) it use an intermediate file named /.../.qgis2/processing/processing_script.r and the results or errors in the file /.../.qgis2/processing/processing_script.r.Rout
The interface
If you look at the resulting processing_script.r, it is possible to see that it uses rgdal
to open the file and save the resulting files, transformed by raster
...
library("raster")
library("rgdal")
Layer = readOGR("path to",layer="Leontot") -> the chosen file
Field="DIP_DIR" -> the chosen field
by=100 -> the mesh size
....
kriging_result = autoKrige(A~1, Mesure, Grille,model=c("Cir","Lin","Bes","Wav","Hol","Leg","Per","Pen","Mat","Exc","Spl","Ste"))
prediction = raster(kriging_result$krige_output)
Output<-prediction
writeRaster(Output,"/var/folders/k9/7s3l5fvd5g1dy31b6sms18fr0000gn/T/processinga3894c34cc084250849b9dba9fe06856/f61b07d41ae54f72bb8d4e1298939fe4/Output.tif", overwrite=TRUE)
Threfore:
- you can examine the error in the file /.../.qgis2/processing/processing_script.r.Rout
or you can directly use R or RStudio to execute this file and control the errors (why raster
cannot find sp
)
R processing_script.r
New
as.factor(LayerField) : Objekt LayerField nicht gefunden Ausführung angehalten = as.factor(LayerField): object LayerField not found execution suspended
You should not modify the original processing_script.r script but run it in R.
The correct command is
Y<-as.factor(Layer[[Field]])
If I use RStudio to control the script:
Layer = readOGR("path_of",layer="sud_for_automap")
# the field chosen in the interface (Field)
Field="DIP_DIR"
# the values in the field
Layer[[Field]]
[1] 156 154 173 158 163 160 147 160 185 185 160 160 160 165 155 162 164 154 163 165
[21] 160 162 184 180 175 168 170 172 164 168 165 178 152 175 169 173 165 187 168 168
....
It is the same as
Layer$DIP_DIR
[1] 156 154 173 158 163 160 147 160 185 185 160 160 160 165 155 162 164 154 163 165
[21] 160 162 184 180 175 168 170 172 164 168 165 178 152 175 169 173 165 187 168 168
.....