Description Usage Arguments Details Value Examples
View source: R/pophelperSpatial.R
Spatially interpolate a qlist using xy coordinates
1 2 3 4 5 6 7 8 9 | plotQInterpolate(qlist = NULL, coords = NULL, method = "krig",
coordsratio = NA, duplicate = "mean", idwpower = 2, clusters = NA,
gridsize = 60, imgoutput = "join", colours = NA, nrow = NA,
ncol = NA, plotcolour = "grey30", exportplot = TRUE, imgtype = "png",
height = NA, width = NA, units = "cm", res = 200, showaxis = FALSE,
addpoints = TRUE, pointcol = "grey10", pointtype = "+", pointsize = 4,
pointalpha = 1, legend = TRUE, legendpos = c(0.99, 0.99),
legendjust = c(1, 1), legendkeysize = NA, legendtextsize = NA,
dataout = FALSE)
|
qlist |
A qlist (list of dataframes) with one element. An output from |
coords |
A dataframe. The number of rows must be equal to the number of individuals in qlist. The dataframe must have 2 columns in the order: x (latitude) and then y (longitude). Coordinates must be in standard longitude latitude (LL) decimals. eg: 21.0232, 43.0232 |
method |
A character indicating the method employed for interpolation. Options are "bilinear", "bicubic", "krig" (Kriging), "idw" (Inverse distance weighting) or "nn" (nearest neighbour). See Details for more information. |
coordsratio |
A numeric indicating ratio between x and y axes. If set to 1, then 1 unit on x axis is the same as 1 unit on y axis. |
duplicate |
A character indicating how to deal with duplicate spatial locations. This is only applicable to 'bilinear' and 'bicubic' methods. Options are "error" (error message if duplicate points), "strip" (remove all duplicate points), "mean" (mean of duplicate points), "median" (median of duplicate points). |
idwpower |
A numeric indicating the power of inverse distance weighting if method is set to "idw". Default set to 2. |
clusters |
A numeric or numeric vector indicating the clusters to plot. If NA, all clusters are plotted. For ex. If set to 2, cluster 2 is plotted. If set to 2:4, clusters 2, 3 and 4 are plotted. If set to c(1,4,5), clusters 1, 4 and 5 are plotted. |
gridsize |
A numeric indicating the size of the image grid on which interpolation is to be carried out. Set to 60 by default. Higher values produces less pixelated grids, but more computationally intensive. |
imgoutput |
A character. To plot each cluster as a seperate figure, set to "sep". To plot multiple clusters in a single figure, set to "join". If number of clusters is less than 2, then automatically set to "sep" with a warning. |
colours |
A vector of 2 or more colours. R colour names or hexadecimal values. Set to 9 value 'Blues' palette from RColorBrewer by default. |
nrow |
A numeric indicating the number of rows of plots in a joined plot. Determined automatically
if number of plots <20 and |
ncol |
A numeric indicating the number of columns of plots in a joined plot. Determined automatically
if number of plots <20 and |
plotcolour |
A character R colour or hexadecimal denoting colour for plot elements. Defaults to "grey30". |
exportplot |
A logical. If set to FALSE, no image is exported. |
imgtype |
A character indicating the export format for figures. Options are "png", "jpeg" or "pdf". If pdf, height and width must be in inches and res argument is ignored (set to 300). |
height |
A numeric indicating the height of export figure in cm unless units are changed. |
width |
A numeric indicating the width of export figure in cm unless units are changed. |
units |
A character indicating units of measurement for figure dimensions. Set to 'cm' by default. |
res |
A numeric indicating the pixel resolution of the export image. Set to 200 by default. |
showaxis |
A logical. If TRUE, then axis text, axis ticks and plot border are plotted. |
addpoints |
A logical. If TRUE, then sample coordinates are overplotted on interpolated grid. |
pointcol |
Colour of sample points. An R colour or hexadecimal value. |
pointtype |
The shape/pch of sample points. A numeric or a character. Eg: 18,19,21,"x" etc. |
pointsize |
The numeric indicating size of sample points. A number usually 0.4,0.8,1,3 etc. |
pointalpha |
A numeric between 0 and 1 indicating transparency of points. Default set to 1. |
legend |
A logical. If TRUE, the legend for the colours is plotted. |
legendpos |
A character of 2-value numeric vector indicating the position of the legend. If "right","left","top" or "bottom", then, legend is plotted outside the plot area. To plot inside plot area use a 2 vale vector. If a vector like c(1,1), first value denotes x-axis from 0 to 1 and second value denotes y-axis from 0 to 1. For ex. to plot in bottom left corner, use c(0,0). |
legendjust |
The x and y axis justification of the legend. A 2 value vector or one of "right","left","top" or "bottom". |
legendkeysize |
A numeric indicating the size of the legend key in cm. Usually values like 0.5,0.7,1.2 etc. |
legendtextsize |
A numeric indicating the size of the text in the legend. |
dataout |
A logical. If set to TRUE, a list of one or more |
The "bilinear", "bicubic", "idw" and "nn" are essentially direct interpolation
between spatial points. The "krig" option is predictive rather than direct interpolation.
The kriging function is same function provided by the TESS authors in their R script.
The function uses great circle distances rdist.earth()
from fields
package to
determine theta. Therefore coordinates must be in LL and not UTM.
For more details of methods, see R package akima
function interp
for "bilinear"
and "bicubic" methods, see R package fields
function Krig
for "krig" method, see
R package spatstat
function idw
for "idw" and function nnmark
for "nn" method.
The model for "krig" is automatically determined and may produce warning messages if
the GCV algorithm does not converge optimally. This shouldn't be an issue for exploratory
analyses. All methods require full coordinate data. No missing data allowed in coords.
If dataout=TRUE
, a list of one or more ggplot
gtable output is returned for more theme
control if required.
1 2 3 4 5 6 7 8 9 10 11 12 | ## Not run:
# tess files
q <- readQ(list.files(path=system.file("files/tess", package="pophelperSpatial"), full.names=T))[1]
xy <- read.delim(system.file("files/coords75.txt", package="pophelperSpatial"), header=F)
plotQInterpolate(qlist=q, coords=xy)
# adjust dimensions and legend size as required
plotQInterpolate(qlist=q, coords=xy, height=15, width=22, legendkeysize=0.4)
# finer grid # very slow
plotQInterpolate(qlist=q, coords=xy, height=15, width=22, legendkeysize=0.4, gridsize=100)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.