Bug report #14608

Processing: Kriging rscripts/Kriging.rsx Automap problem and correction

Added by Martin Laloux over 1 year ago. Updated 7 months ago.

Status:Closed
Priority:Normal
Assignee:Victor Olaya
Category:Processing/Core
Affected QGIS version:2.14.0 Regression?:No
Operating System:Mac OS X Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No

Description

There is a problem with

kriging_result = autoKrige(A~1, Mesure, Grille,model=c("Cir","Lin","Bes","Wav","Hol","Leg","Per","Pen","Mat","Exc","Spl","Ste"))
library(raster)
result<-raster(prediction)
Output<-result

1) prediction is not defined in the script
2) if prediction == kriging_result then with automap, you need prediction = raster(kriging_result$krige_output)

The solution is

library(raster)
prediction raster(kriging_result$krige_output)
Output<-prediction

History

#1 Updated by Martin Laloux over 1 year ago

A script that works, without the not required package (gstats, rgl, ....)

##Basic statistics=group
##showplots
##Layer=vector
##Field=Field Layer
##by=number 0.1
##Output=output raster
library(automap)
library(raster)
Y<-as.factor(LayerField)
attribut<-as.data.frame(Y)
A<-as.numeric(Y)
for(j in (1:length(levels(Y))))
for(i in 1:dim(attribut)[1]){
if (attribut[i,1]==levels(Y)[j]){
A[i]=j
}
}
coords<-coordinates(Layer)
MinX<-min(coords[,1])
MinY<-min(coords[,2])
MaxX<-max(coords[,1])
MaxY<-max(coords[,2])
Seqx<-seq(MinX, MaxX, by=by)
Seqy<-seq(MinY, MaxY, by=by)
MSeqx<-rep(Seqx, length(Seqy))
MSeqy<-rep(Seqy, length(Seqx))
MSeqy <- sort(MSeqy, decreasing=F)
Grille <- data.frame(X=MSeqx, Y=MSeqy)
coordinates(Grille)=c("X","Y")
gridded(Grille)<-TRUE
Mesure<- data.frame(LON=coords[,1], LAT=coords[,2],A)
coordinates(Mesure)<-c("LON","LAT")
variogram = autofitVariogram(A~1, Mesure)
plot(variogram)
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

#2 Updated by Victor Olaya over 1 year ago

  • Status changed from Open to Closed

#3 Updated by Giovanni Manghi 7 months ago

  • Regression? set to No

#4 Updated by Giovanni Manghi 7 months ago

  • Easy fix? set to No

#5 Updated by Giovanni Manghi 7 months ago

Some providers are being removed from QGIS/Processing (will be available as plugin) and so are their categories in the bug tracker. To not leave them orphaned of a category they are being reassigned to processing/core.

#6 Updated by Giovanni Manghi 7 months ago

  • Category changed from 124 to Processing/Core

Also available in: Atom PDF