gists2spt {hydroTSM}R Documentation

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 measurement points as you want, e.g., all the gauging stations in your database, but
-) It HAVE TO contain -at least- the location of the measurement points of x.ts that will be used for the interpolations.
The MINIMUM fields that HAVE TO be present in this file, and their corresponding column index are X, Y, sname.

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 stations in the your database, but
2) It HAVE TO contain -at least- some stations of x.gis

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 x.gis

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 x.gis

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 == catchment.name will be used.

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

If p4s is given, the returning object will be a SpatialPointsDataFrame-class, if not, it will be a data.frame

Author(s)

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

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://rspatial.r-forge.r-project.org/

See Also

krige, spplot

Examples

############
## 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")

[Package hydroTSM version 0.5-1 Index]