Learn R Programming

covatest (version 0.2.1)

dataprep: Imports a GSLIB file in R

Description

Imports a GSLIB file and convert it into a data frame or in a STFDF, according to the standard of the spacetime package.

Usage

dataprep()

Arguments

Value

object of the STFDF-class or data frame, which contains coordinates of the spatial points, the identification code of the spatial locations, the indentification code of the temporal observations and the observed values of the variable

Details

The function requires the user to set some external arguments, that is:

  1. the GSLIB file name and its extension

  2. the number of variables in the file

  3. the code of missing values

  4. the column in which the coordinates of the spatial points are stored

  5. the number of different spatial points

  6. the flag for using/not using an existing identification ID for the spatial locations

  7. the column in which the time coordinates are stored

  8. the number of temporal observations for each spatial point

  9. the column in which the values of the variable are stored

Moreover it is allowed the user to choose between two options for saving the data: 1. save the data as an STFDF (spacetime class) 2. save the data as a data frame. If the first option is selected (save the data as a STFDF), it is also necessary to specify

  • the Start Date of the STFDF

  • the interval of time between two temporal observations

The user must provide the aforementioned arguments concerning the structure of the GSLIB file in order to convert it in a data frame or in a STFDF

References

Bivand, R. S., Pebesma, E., Gomez-Rubio, V., 2013, Applied spatial data analysis with R, Second edition. New York: Springer. http://www.asdar-book.org/

Pebesma, E.J., 2012, spacetime: Spatio-Temporal Data in R. Journal of Statistical Software, 51(7) 1--30. http://www.jstatsoft.org/v51/i07/

Remy, N., Boucher, A., Wu, J, 2009, Applied Geostatistics with SGeMS: A User's Guide. Cambridge

See Also

STFDF

Examples

Run this code
# NOT RUN {
## The function requires to set some external arguments.
# In the GSLIB file, used as example, the measurements of PM10 in 13 rural
# background monitoring stations, in the period 2005-2006  (730 days), are
# stored. The information required to load the dataset concern:
# - the file name and its extension: PM10data.txt
# - the number of variables in the file: 6
# - the code of missing values: -999
# - the column in which the x coordinates are stored: 1
# - the column in which the y coordinates are stored: 2
# - the number of different spatial points: 13
# - the availability of an identification id for all the spatial points: y
# - the column in which the time coordinates are stored: 5
# - the number of temporal observations for each spatial point: 730
# - the column in which the values of the variable are stored: 6
# The user could choose to save the data as STFDF (option 1) or dataframe
# (option 2). If the option 1 will be choosen, it is also necessary to specify:
# - the Start Date: 2005-01-01
# - the interval of time between two temporal observations: day

# To run the example, paste and copy the following lines
# (without the symbol '#') in the console
#
#datafile <- dataprep()
#PM10data.txt
# 5
#-999
#1
#2
#13
#y
#4
#730
#5
#1
#2005-01-01
#day
# }

Run the code above in your browser using DataLab