5

The answer below solved my fist question, so I edit my question as follows:

I have a shapefile given with the attributes lat, lon, elevation and temperature.

So far I have a script that interpolates only the temperature data:

#read shapefile:    
shape <- readOGR("C:/Users.../Testarea.gdb", "temperature_data")
#grid shapefile:
shape.grid <- spsample(shape, type = "regular", offset = (c1,1))
gridded(shape.grid) <- TRUE

#kriging:
test <- krige(Temperatur~1, shape, shape.grid)
spplot(test[[1]])

Now my problem is that I should also need to consider the elevation, since the temperature is often dependant on this parameter. How can I do this?

  • With r questions it's useful to provide a minimal reproducible example so we can test solutions. Can you edit your question either to include a link to your shapefile, either in its original location or use a file sharing site? – Phil Mar 4 '16 at 16:47
  • I'm really curious... Are you attempting this in the R-ArcGIS Bridge, or running in straight R? – Priscilla Mar 4 '16 at 21:39
  • I will upload a shape file tomorrow. I have a R-Arcgis bridge running but first I want to do a stand-alone script and then maybe later edit it to implement the script into arcgis :) – Moritz Mar 5 '16 at 15:20
  • I uploaded my .gdb with the shapefile to my google drive: drive.google.com/… Any help would be greatly appreciated :) – Moritz Mar 6 '16 at 18:59
  • 1
    @Phil did you get the chance to try a solution to interpolate the data considering the elevation? :) – Moritz Mar 10 '16 at 7:47
5

You didn't pass shape.grid to krige. Try:

library(gstat)
test = krige(Temperatur ~ 1, shape, shape.grid)
spplot(test[1])

Your example does not work as is, ssample should have been spsample. For your second question, you will need a grid with elevation data.

  • Thanks, i edited my sample from ssample to spsamle. Still, your script edit does not give me the kriged data, instead i only get a grid. I uploaded my gdb in the comments to my original post, maybe you could take a look at it? Thanks for your help! – Moritz Mar 6 '16 at 19:09
  • use spplot instead of plot; I edited my answer. – Edzer Pebesma Mar 7 '16 at 9:10
  • Thank you! The spplot works just fine. Now the only trouble is that i did not consider the elevation yet. – Moritz Mar 7 '16 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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