Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9006161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:20:17+00:00 2026-06-16T01:20:17+00:00

I am trying to write a code in R that use gstat library in

  • 0

I am trying to write a code in R that use gstat library in order to create an interpolation.
I have already read the gstat manual and based on some examples on internet I had managed to write this code (this is only a part):

 g <- gstat(id="tec", formula=TEC ~ 1, data=data)  ##I create an object
 v <- variogram(g) # plot the empirical variogram
 plot(v)
 mod<-vgm(sill=var(data$TEC),model="Sph",range=200,nugget=200) #create the variogram model

v.fit <- fit.variogram(v, model=mod,fit.method=1)  #fit the empirical variogram 
Theor_variogram=plot(variogram(g),v.fit,main="WLS Model") #plot the theoretical variogram
plot(Theor_variogram)
 ## Kriging interpolation
 p <- predict.gstat(g, model=v.fit, newdata=predGrid)

My problem is that, when I run the last command (predict) instead of getting a result with ordinary kriging interpolation, I get one with inverse distance weighted (IDW).
I read in the gstat manual that: “When no variograms are specified, inverse distance weighted interpolation
is the default action.
When variograms are specified the default prediction method is ordinary
kriging.”

But, as you can see in my code, I specify both the empirical and theoretical variogram.
Do you know why I keep getting IDW instead of ordinary kriging? Can it be related with the type of coordinates that I have? If for example I have coordinates close to each other, or if the region of interest is too big?
Any help would be really useful.

Thanks in advance
Dimitris

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:20:18+00:00Added an answer on June 16, 2026 at 1:20 am

    You need to include the creation of the gstat object, not in de prediction phase:

    g <- gstat(id="tec", formula=TEC ~ 1, data=data, model = v.fit)
    

    However, I would recommend using the standard interface for gstat using krige. This combines the building of the gstat object and the prediction into one functions. Very rarely do you need to build gstat objects yourself. For example:

    data(meuse)
    coordinates(meuse) = ~x+y
    data(meuse.grid)
    gridded(meuse.grid) = ~x+y
    m <- vgm(.59, "Sph", 874, .04) 
    # OK:
    x <- krige(log(zinc)~1, meuse, meuse.grid, model = m)
    

    You could also use the automap package (which I am the author of) and let the variogram model be automatically fitted to the data. For example using the meuse dataset:

    library(automap)
    kr = autoKrige(log(zinc)~1, meuse, meuse.grid)
    

    This will automatically build a sample variogram, and fit a variogram model to that sample variogram.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a code that helps me to create a XML
I am trying to write some XS code that exposes pieces a library to
I m trying write code that after reset set up rrpmax as 3000. It
I'm trying to write code that will load an image from a resource, and
I've been trying to write code that loads a .png file, attaches hotspot information,
I'm trying to write a code that adds a class to a div for
I am trying to write some code that will generate accurate .proto files from
I'm trying to write a code that could print something like this -xv -xvv
I am trying to write some code that that will draw the line which
I am currently trying to write some code that will accept some FTP details,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.