[R-sig-Geo] subplots of maps in R using hydroTSM package
Zilefac Elvis
zilefacelvis at yahoo.com
Sun Nov 23 18:13:12 CET 2014
Hello,
Please I need help with maps in R using the hydroTSM package.
I am doing some map work using this wonderful package but encountered a problem using "par".
My intention is to generate 4 plots and show them on same window as follows:
if (dev.cur() == 1) x11(width=14,height=8)
par(mfrow=c(4,4),mai = c(0.8, 0.6, 0.1, 0),oma=c(0,1.4,6,0.1))
library(hydroTSM)
############
## 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
# European Datum 50, Zone 30N
require(sp)
p4s <- CRS("+proj=utm +zone=30 +ellps=intl +units=m +no_defs")
## Selecting the first day of 'EbroPPtsMonthly' for all the stations.
# The first column of 'EbroPPtsMonthly' has the dates
x.ts <- as.numeric(EbroPPtsMonthly[1, 2:ncol(EbroPPtsMonthly)])
## Setting the name of the gauging stations
names(x.ts) <- colnames(EbroPPtsMonthly[1,2:ncol(EbroPPtsMonthly)])
##################################################
## 1) IDW interpolation and plot
## Probably you will need to resize your window
## Not run:
x.idw <- hydrokrige(x.ts= x.ts, x.gis=EbroPPgis,
X="EAST_ED50", Y="NORTH_ED50", sname="ID", bname="CHE_BASIN_NAME",
type= "cells",
subcatchments= EbroCatchmentsCHE,
cell.size= 3000,
ColorRamp= "Precipitation",
main= "IDW Precipitation on the Ebro")
## End(Not run)
However, the existing plot disappears everytime I run this code.
Question1: How can I run this code 4 times and show the 4 maps on 1 plot window as defined by
par(mfrow=c(4,4))?
Question2: Is it possible to convert the X and Y axes values from UTM to lat and lon and show them on the map?
Many thanks for your insighful replies.
Zilefac.
More information about the R-sig-Geo
mailing list