Description Usage Arguments Author(s) References See Also Examples
Plots several spatial maps in the same plotting window, with options to easily add a scale bar and north arrow.
Originally, it was though to make easier the display of several maps (of the same spatial extent) obtained by different interpolation methods or for different time steps.
1 2 3 4 5 |
x |
SpatialPixelsDataFrame-class object that stores (in the |
subcatchments |
SpatialPolygonsDataFrame-class with all the subcatchments within the study area, OR character representing the filename (with path) of the shapefile ('polygon' type) that stores those subcatchments. |
IDvar |
See readShapePoly. Character string with the name of a column in the |
p4s |
Character with information about the projection of the GIS files, usually created by the CRS function of the sp package |
plot |
Logical, indicating if the interpolated values have to be plotted or not |
ColorRamp |
Character or function defining a personalized color ramp for plotting the maps. |
col.nintv |
integer, number of colors that have to be used for plotting the interpolated values |
col.at |
Specify at which interpolated values colours change. Valid values are: |
main |
Character with the title to be used for the plot |
stations.plot |
Logical, indicating if the gauging stations, defined by |
stations.gis |
OPTIONAL. data.frame with the stations that will be added to the plot. ONLY required when |
X |
OPTIONAL. character, field name in |
Y |
OPTIONAL. character, field name in |
arrow.plot |
Logical, indicating if a North Arrow have to be plotted |
arrow.offset |
OPTIONAL. 2D list with the numeric coordinates in which the North Arrow have to be plotted. e.g., arrow.offset = c(690000,4760000). ONLY required when |
arrow.scale |
OPTIONAL. Scale (in the map units) to be used for plotting the North Arrow, e.g., scale = 20000. ONLY required when |
scalebar.plot |
Logical, indicating if a Scale Bar have to be plotted |
sb.offset |
OPTIONAL. 2D list with the numeric coordinates in which the North Arrow have to be plotted. e.g., sb.offset = c(400000,4490000). ONLY required when |
sb.scale |
OPTIONAL. Scale (in the map units) to be used for plotting the Scale Bar, e.g., scale = 100000, means that the scale bar will have a length of 100km. ONLY required when |
verbose |
logical; if TRUE, progress messages are printed |
Mauricio Zambrano-Bigiarini, mzb.devel@gmail
Applied Spatial Data Analysis with R. Series: Use R. Bivand, Roger S., Pebesma, Edzer J., Gomez-Rubio, Virgilio. 2008. ISBN: 978-0-387-78170-9
http://rspatial.r-forge.r-project.org/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | ## Loading the monthly time series of precipitation within the Ebro River basin.
data(EbroPPtsMonthly)
## Loading the gis data
data(EbroPPgis)
## Loading the shapefile with the subcatchments
data(EbroCatchmentsCHE)
## Projection for the Subcatchments file
require(sp)
p4s <- CRS("+proj=utm +zone=30 +ellps=intl +units=m +no_defs")
## Field name in 'x.gis' with the ID of the station
sname <- "ID"
## Field name in 'x.gis'with the name of the catchment to which each station belongs
bname <- "CHE_BASIN_NAME"
## Field name in 'x.gis' with the Easting spatial coordinate
X <- "EAST_ED50"
## Field name in 'x.gis' with the Northing spatial coordinate
Y <- "NORTH_ED50"
## Field name in 'x.gis' with the Elevation
elevation <- "ELEVATION"
#######
## Selecting Jan/1961 (first row) of 'EbroPPtsMonthly' in all the stations
x.ts <- as.numeric(EbroPPtsMonthly[1, 2:ncol(EbroPPtsMonthly)])
## Setting the name of the stations
names(x.ts) <- colnames(EbroPPtsMonthly[ ,2:ncol(EbroPPtsMonthly)])
########
## IDW interpolation and plot (Jan/61)
x.idw <- hydrokrige(x.ts= x.ts, x.gis=EbroPPgis,
X=X, Y=Y, sname=sname, bname=bname, elevation=elevation,
type= "cells", #'both'
subcatchments= EbroCatchmentsCHE, p4s= p4s,
cell.size= 3000, nmax= 50,
ColorRamp= "Precipitation",
main= "IDW Mean Annual Precipitation on the Ebro, Jan/1961")
## Storing the interpolated values
x.idw@data["Jan1961"] <- x.idw@data["var1.pred"]
x.idw@data["var1.pred"] <- NULL
x.idw@data["var1.var"] <- NULL
## Selecting the Jul/1961 of 'EbroPPtsMonthly' for all the stations
x.ts <- as.numeric(EbroPPtsMonthly[7, 2:ncol(EbroPPtsMonthly)])
## Setting the name of the stations
names(x.ts) <- colnames(EbroPPtsMonthly[ , 2:ncol(EbroPPtsMonthly)])
## IDW interpolation and plot (Jul/1961)
x.idw2 <- hydrokrige(x.ts= x.ts, x.gis=EbroPPgis,
X=X, Y=Y, sname=sname, bname=bname, elevation=elevation,
type= "cells", #'both'
subcatchments= EbroCatchmentsCHE, p4s= p4s,
cell.size= 3000, nmax= 50,
ColorRamp= "Precipitation",
main= "IDW Mean Annual Precipitation on the Ebro, Jul/1961")
# Adding the interpolated value for Jul/1961 to 'x.idw'
x.idw@data["Jul1961"] <- x.idw2@data["var1.pred"]
## Plotting in the same graph the 2 interpolated fields
mspplot(x=x.idw,
subcatchments=EbroCatchmentsCHE,
IDvar=NULL, p4s,
col.nintv=50,
main="IDW Monthly Precipitation on the Ebro River basin, [mm]",
stations.plot=FALSE,
arrow.plot=TRUE, arrow.offset=c(900000,4750000), arrow.scale=20000,
scalebar.plot=TRUE, sb.offset=c(400000,4480000), sb.scale=100000)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.