Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
In case of continuously collected data, e.g. observations from a monitoring network, spatial interpolation of this data cannot be done manually. Instead, the interpolation should be done automatically. To achieve this goal, I developed the automap package. automap builds on top of the excellent gstat package, and provides automatic spatial interpolation, more specifically, automatic kriging. Kriging in its more simple form (Ordinary Kriging, Universal Kriging, aka Kriging with External Drift) is actually nothing more than linear regression with spatially correlated residuals.
automap provides the following set of functions (for details I refer to the online manual):
autofitVariogram, automatically fits the variogram model to the data.autoKrige, automatically fits the variogram model usingautofitVariogram, and creates an interpolated map.autoKrige.cv, automatically fits the variogram model usingautofitVariogram, and performs cross-validation. Useskrige.cvunder the hood.compare.cv, allows comparison of the output ofautoKrige.cvandkrige.cv. This can be used to evaluate the performance of different interpolation algorithms.compare.cvallows comparison using both summary statistics and spatial plots.
In general, the interface of automap mimics that of gstat. The following code snippets show some examples of creating interpolated maps using automap:
library(automap) loadMeuse() # Ordinary kriging kriging_result = autoKrige(zinc~1, meuse, meuse.grid) plot(kriging_result) # Universal kriging kriging_result = autoKrige(zinc~soil+ffreq+dist, meuse, meuse.grid) plot(kriging_result)
You can get automap from either CRAN:
install.packages("automap")
hg clone https://bitbucket.org/paulhiemstra/automap
PS: automap was the first package I wrote, at the beginning of my PhD, so it is not the most beautiful code I ever wrote
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
