## Not run: ######################################################
# # Example 1. #
# ######################################################
#
# # Need the data.frame botnv.2004 to be able to compile this
# # example, if not attached use:
# # >attach("/usr/local/reikn/Splus5/Aflaskyrslur/Data")
#
# codgrd <-list(lat = seq(62, 68, by = 0.1), lon = seq(-30, -9, by = 0.25))
# # A grid is made.
# lab.loc<-list(lat = c(63.9, 65.6), lon = c(-20.75, -16.5))
# # Location of the label.
#
# tmp <- combine.rt(botnv.2004$lat, botnv.2004$lon,
# botnv.2004$torskur, codgrd, fun = "sum", fill = TRUE)
# # The data is read into the grid with combine.rt.
#
# tmp$z <- tmp$z/(cos(tmp$lat*pi/180)*0.1*60*0.25*60)
# # Data changed.(from being in
# # kilos per box to kilos per square mile).
#
# vg <- list(nugget = 0.1, sill = 1, range = 50)
# # Parameters for the variogram
#
# z <- pointkriging(tmp$lat, tmp$lon, tmp$z, codgrd, vg,
# maxnumber = 80, maxdist = 30, set = -1)
# # Dataset smoothened with pointkriging.
#
# geoplot(lat = c(63, 67.5), lon = c(-27, -11), grid = FALSE, axlabels = TRUE, type = "n")
# # Plot initialized
# level = c(160, 200, 320, 500, 700, 1000, 2000, 3000, 4000, 5000, 6000)
# # Levels for geocontour.fill
#
# geocontour.fill(codgrd, z, levels = level, white = TRUE # Plot the data.
# , working.space = 300000)
#
# geopolygon(island)
# # Contourlines inside Iceland overwritten.
# geolines(island)
# # Iceland redrawn with geolines.
#
# geocontour.fill(codgrd, z, levels = level, white = TRUE,
# label.location = lab.loc, labels.only = TRUE)
# # Call geocontour.fill again only to plot the labels.
#
# #########################################################
# # Example 2. #
# #########################################################
#
#
# # Preperation for pointkriging
# # th4.2002 is the data used here, dataframe [lon, lat, mat].
# # >attach(?????)
#
#
# grd.smb <-list(lat = seq(62.8, 67.5, length = 80), # Set up the grid.
# lon = seq(-28, -10, length = 130))
# m.lev<-c(0, 0.1, 0.2, 0.3, 0.5)
# # Levels for the geocontour.fill.
# m.col<-c(0, 14, 59, 104, 119, 149)
# # Colors for the levels.
# lab.in.island<-list(lat = c(63.9, 65.6), lon = c(-20.75, -16.5))
# # Location of the Label
#
# vg <- list(nugget = 0.3, sill = 1, range = 50)
# # Initialize variogram parameters.
#
# zfj<-pointkriging(th4.2002$lat, th4.2002$lon, z = th4.2002$mat,
# grd.smb, vg, maxnumber = 80, maxdist = 30, set = -1)
# # Smooth the data with pointkriging.
#
# #
# # Plotting
# #
#
# par(mfrow = c(1, 1), mai = rep(0, 4))
# # Set up graphic parameters.
# geoplot(lat = c(63, 67.5), lon = c(-27, -11), grid = FALSE, axlabels = FALSE, type = "n")
# # Draw a background with Iceland with geoplot.
#
# geocontour.fill(zfj, levels = m.lev, col = m.col, working.space = 300000)
# # Plot the data with geocontour.fill.
#
# geopolygon(gbdypif.500, col = 0, exterior = TRUE, r = 0)
# # Remove contours outside gbdypif.500.
# geoplot(lat = c(63, 67.5), lon = c(-27, -11), grid = FALSE, # Replot.
# axlabels = FALSE, type = "n", new = TRUE)
#
# geopolygon(island, col = 43)
# # Remove contours inside Iceland and color Iceland.
# geocontour.fill(zfj, levels = m.lev, label.location = lab.in.island,
# labels.only = TRUE, csi = 0.1, col = m.col, working.space = 300000)
# # Call geocontour.fill to plot labels.
# geolines(island)
# # Redraw the lines of Iceland.
# ## End(Not run)
Run the code above in your browser using DataLab