Learn R Programming

hydroTSM (version 0.3-5)

gists2spt: Time Series and GIS Info -> (pseudo)Spatio-Temporal Object

Description

Given a data.frame (x.gis) with the spatial coordinates of a set of measurement points (e.g., gauging stations) and the measurements in those stations (x.ts) this function merges the measurements in x.ts with the corresponding spatial location in x.gis, even if they are not in the same order. If the spatial coordinates X and Y are given for x.gis, the resulting object will be a SpatialPointsDataFrame-class with coordinates given by the X and Y fields If p4s is given, the resulting object will be projected according to the specification provided by p4s.

Usage

gists2spt(x.gis, x.ts, sname, bname, X, Y, elevation,
          catchment.name="all", na.rm=TRUE, p4s)

Arguments

x.gis
data.frame with the spatial information for all the measurement points in x.gis. The name of each station, stored in the field sname, have to be equal to the corresponding ID used in x.ts -) It MAY contain as many m
x.ts
numeric or data.frame with the measured value at each station for a given time. Each value of x.ts has to have as name (names(x.ts)) the ID of the station. 1) It MAY contain as many stations as you want, e.g., all the gauging st
sname
character, field name in x.gis that stores the name of the stations ( the name of the stations have to start by a letter !!)
bname
OPTIONAL. character, field name in x.gis that stores the name of the subcatchment in x.gis that will be analysed. ONLY necessary when 'catchment.name' is not "all"
X
character, field name in x.gis that stores the easting coordinate of the measurement points. The expected name is 'x', but if the value provided by the user is different, a new 'x' field is created and is used as the easting coordinate of
Y
character, field name in x.gis that stores the northing coordinate of the measurement points. The expected name is 'y', but if the value provided by the user is different, a new 'y' field is created and is used as the northing coordinate of <
elevation
OPTIONAL. character, field name x.gis that stores the elevation of the stations (m a.s.l.).
catchment.name
name of the catchment that will be analysed. Possible values are: -)all : ALL the stations in the x.gis will be used -)other character: ONLY those stations in x.gis with a bname field value == <
p4s
Character with information about the projection of the GIS files, usually created by the CRS function of the sp package
na.rm
a logical value indicating whether 'NA' values should be stripped before delivering the resulting object.

Value

References

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://r-spatial.sourceforge.net/gallery/

See Also

krige, spplot

Examples

Run this code
############
## Loading the monthly time series of precipitation within the Ebro River basin.
data(EbroPPtsMonthly)

## Loading the gis data
data(EbroPPgis)    

## Putting the measurements of the first row of 'EbroPPtsMonthly' into their 
## corresponding spatial location given by 'x.gis'
require(sp)
x.spt <- gists2spt(x.ts=EbroPPtsMonthly[1,], x.gis=EbroPPgis, X="EAST_ED50", 
                   Y="NORTH_ED50", na.rm=FALSE, sname="ID")

## Plotting the measured values (only the first row of 'EbroPPtsMonthly') at their 
## corresponding spatial location
spplot(x.spt, zcol="value")

Run the code above in your browser using DataLab