## Not run: Examples shown here below also include calls to the other functions
# in the geopackage. Further explanations of these functions can be
# found in the appropriate help files.
#
# Contour plot of haddock catch in icelandic waters based on logbooks.
# A color scheme
# where color 0 is white, 1 black and 2-150 gradually changing from
# white to black is used. The data is for 6 years and is stored in a
# list hadcatch with 6 components. Circles showing haddock catch in
# the Icelandic groundfish survey is added on top of the plot with the
# function geosymbols but utbrteg is a dataframe with information on all
# catch in the Icelandic groundfish survey (all names in Icelandic ysa
# means haddock and ar year). The function bwps is a call to the
# postscript function with the indicated color scheme. Designed for
# Splus and has to be changed for R as the color schemes there are quite
# different. This applies to all the examples below.
#
# lev <- c(0.5, 1, 2, 4, 6)
# col <- c(0, 30, 50, 70, 90, 150)
# txt <- c(1993, 1995, 2000, 2002, 2005, 2006)
# par(mfrow = c(3, 2));par(mex = 0.01)
# bwps(file = "hadcatchutbr.ps", height = 6.8, width = 6.5, horizontal = FALSE)
# for(i in 1:6) {
# SMB.std.background(grid = FALSE, axlabels = FALSE)
# geocontour.fill(hadcatch[[i]], levels = lev, col = col,
# white = TRUE, working.space = 2e6)
# gbplot(200)
# geotext(67.3, -27.6, txt[i], csi = 0.16, adj = 0)
# geopolygon(island, col = 0);geolines(island)
# tmp <- utbrteg[utbrteg$ar == txt[i], ] # select the year
# geosymbols(tmp, z = tmp$ysa.kg, circles = 0.2,
# sqrt = TRUE, lwd = 1)# amount of haddock
# geopoints(tmp, pch = 16, csi = 0.05)
# }
# dev.off()
#
# # plot x, y data
# geoplot(x$x, x$y, projection = "none", type = "n")
#
# geoplot(x, projection = "none", type = "n")
# # does the same thing.
#
# # The packages maps and mapdata need to be installed
# # worldHires is a very detailed database of coastlines from the
# # package mapdata. Could be problematic if used with fill = TRUE)
# # Allowed.size is the maximum allowed size of polygons.
# library(map) # world coastlines and programs
# library(mapdata) # more detailed coastlines
# geoplot(xlim = c(20, 70), ylim = c(15, 34))
# geoworld(database = "worldHires", fill = TRUE, col = 30, allowed.size = 30000)
#
# geoplot(xlim = c(20, 70), ylim = c(15, 34), dlat = 10, dlon = 10)
# geoworld(database = "world", fill = TRUE, col = 30) #
#
# geoplot(xlim = c(-10, 70), ylim = c(71, 81), b0 = 80,
# dlat = 2, dlon = 10) # 0 must be high here else
# geoworld(database = "world", fill = TRUE, col = 30) #the plot fails.
#
# # Lambert projection,
# geoplot(xlim = c(-10, 70), ylim = c(71, 81),
# dlat = 2, dlon = 10, projection = "Lambert")
# geoworld(database = "world", fill = TRUE, col = 30)
#
# # Lambert projection, get the axis closer with the mgp command
# par(mgp = c(2, 0, 0))
# geoplot(xlim = c(-10, 70), ylim = c(71, 81),
# dlat = 2, dlon = 10, projection = "Lambert", cex = 1.1)
# geoworld(database = "world", fill = TRUE, col = 30)
#
# # Example with capelin data. (lodna meanns capelin). lodna.2 is a
# # data.frame with components lat, lon and z.
# geoplot(lodna.2, type = "l")
# geopoints(lodna.2)
# geosymbols(lodna.2, z = lodna.2$z, colplot = TRUE,
# parbars = 0.05, levels = vor.levels, label.location = labloc)
#
#
# geoplot(lodna.2, type = "l")
# geosymbols(lodna.2, z = lodna.2$z, perbars = 0.1)
#
# geoplot(lodna.2, type = "l")
# geosymbols(lodna.2, z = log(1+lodna.2$z), perbars = 0.1)
#
#
# limits <- list(lat = c(63, 68), lon = c(-30, -10))
# geoplot(xlim = limits, type = "n", grid = FALSE, axlabels = TRUE, plot = FALSE)
# tmp <- geoexpand(lodna.2.grd) # expand the grid
# # has defined ther area vor.area and data outside it are set to NA.
# i <- geoinside(tmp, vor.area.new, option = 0)
# zgr <- z.lodna.2;zgr[-i] <- NA
# geocontour.fill(lodna.2.grd, z = zgr, white = TRUE,
# label.location = labloc, levels = vor.levels)
# geoplot(xlim = limits, type = "n", grid = FALSE, axlabels = TRUE, new = TRUE)
# #geolines(lodna.2, lwd = 1)
# gbplot(c(200, 500)) # Depth contours.
#
# # make a plot of number within a square, calculate the total number of
# #cod (torskur) within a square (reitur) and put the text number of
# #square and total number of cod in the center of the square (number of
# #cod below number of square). Apply.shrink is similar to tapply
# #returning the data in different form and is included with the geo library
#
# geoplot(island, r = 1.2, type = "n", reitur = TRUE)
# x <- apply.shrink(data$torskur.stk, data$reitur, sum,
# names = c("reitur", "torskur.stk"))
# x1 <- r2d(x$reitur)
# geotext(x1, z = paste(x$reitur, round(x$torskur.stk, 1), sep = "\n"))
#
# # Plot filled circles. The color scheme used is the same as described
# # color 0 white, 1 black and 2 - 155 white-black see bwps
# # in geosymbols the argument color means size (in inches)
# # when the fill.circles = TRUE. The data used AfliBySquareMonthYear have
# # the columns year, month , square and catch.
# # the function r2d changes square (reitur in Icelandic) to position
# # Text is put in the middle of the circles where catch exceeds 1000
# # tonnes.
#
# my.colors = c(0.004, 0.04, 0.1, 0.15, 0.20, .25, 100)
# lev <- c(0.2, 2, 7.5, 10, 20, 50)
#
# yy <- c(1932:1939)
# tmp4 <- AfliBySquareMonthYear
# tmp4$catch <- tmp4$catch/1000
# for (ar in yy) {
# bwps(file = paste(ar, ".ps", sep = ""))
# par(omi = c(0, 0, 0, 2))
# par(mfrow = c(4, 3))
# par(mex = 0.01)
#
# for(man in 1:12){
# tmp1 <- tmp4[tmp4$year == ar & tmp4$month == man, ]
# SMB.std.background(axlabels = FALSE, country = "none", plotit = FALSE)
# if(nrow(tmp1) > 0) {
# tmp2 <- apply.shrink(tmp1$catch, tmp1$square, sum,
# names = c("square", "catch"))
# tmp2 <- tmp2[order(-tmp2$catch), ]
#
# tmp3 <- data.frame(r2d(tmp2$square))
# geosymbols(tmp3, z = tmp2$catch, fill.circles = TRUE, col = 60,
# levels = lev, colors = my.colors, bordercol = 0, border = TRUE)
# geopolygon(island, col = 30)
# geolines(eyjar, lwd = 3, col = 30)
# j <- tmp2$catch > 1
# if(any(j)) {
# tmp3 <- tmp3[j, ]
# tmp2 <- tmp2[j, ]
# geotext(lat = tmp3$lat, lon = tmp3$lon, z = tmp2$catch,
# angle = 45, csi = 0.1)
# }
# geotext(lat = c(65.2), lon = (-18), z = paste(month.abb[man],
# round(sum(tmp2$catch, na.rm = TRUE)), sep = "\n"), csi = 0.2)
# }
# else {geotext(lat = c(65.2), lon = (-18),
# z = paste(month.abb[man], "0", sep = "\n"), csi = 0.2)}
# }
# geotext(63, -10, ar, adj = 1, csi = 0.18)
# dev.off()
# }
# ## End(Not run)
Run the code above in your browser using DataLab