Skip to content

Spatio-Temporal objects and kriging

2 messages · Bruno Sesti, Dr. Benedikt Gräler

#
Hi, I have some questions about spatio temporal objects and kriging, I have
done some research to try to solve this problems but I did not find any
answer.
I would Like to know if and, if yes, how could be possible to convert a
STIDF object to a SpatialPointsDataFrame object.
The second issue is if and how it could be possible to plot the map(s)
obtained through the function krigeST over an open street map or a Google
map layer in R environment and/or in other gis environments.

Kind regards.
#
Dear Bruno,
On 14.06.2018 08:40, Bruno Sesti wrote:
You can simply coerce it to "Spatial", note that the class of your 
projected Spatial-Obj will depend on the class of the spatial slot of 
your STIDF-Obj:

library(sp)
library(xts)
library(spacetime)

data("meuse")
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")

stidf <- STIDF(geometry(meuse), xts(1:length(meuse), Sys.time() - 
(1:length(meuse))*24*3600), meuse at data)

spdf <- as(stidf, "Spatial")

spplot(spdf, "copper")
The function stplot re-uses the function spplot, hence you could use the 
mechanisms of overlaying base maps with your interpolated values (i.e. 
via sp.layout):

data(meuse.riv)
meuse.sr = 
SpatialPolygons(list(Polygons(list(Polygon(meuse.riv)),"meuse.riv")))
stplot(stidf[,,"copper"], sp.layout=list("sp.polygons", 
fill="lightblue", meuse.sr))

The package plotKML allows to directly plot an STIDF-Obj in Google Earth 
including the temporal domain allowing for a quick animation:

library(plotKML)
plotKML(stidf)

Generally, one will have to pick an appropriate (exchange) format that 
respects time and is understood by R and your favorite GIS. A slice wise 
pure spatial export/plot is of course also an option, i.e. looping 
through all relevant timestamps and exporting e.g. a geotiff each or 
using the same techniques as in the pure spatial case.

HTH,

  Ben