-2

I need to create a rainfall raster with cubic spline in R, but I don't know what to do.I have precipitation heights and coordinates of the point where they are measured. Can anyone help me?I tried with Tps function but I need to insert: tension type, weight=0.4 and neighbors=5.

library(gstat)
library(raster)
library(rgdal)
library(fields)
setwd("C:/Users/B/Desktop/DatiPrecipitazioni/dati")
mydata<-read.csv(file="2016_01.csv",header=TRUE,sep=";",dec=".",na="")
DTM=raster("Dtm1.tif")
crs(DTM) <-"+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9996 +x_0=2520000 +y_0=0 +ellps=intl +towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68 +units=m +no_defs"
coordinates(mydata)= ~x+y
m<-Tps(coordinates(mydata),mydata$HPrec)
tps<-interpolate(DTM,m)
tps<-mask(tps,DTM)
contorno=readOGR(dsn="C:/Users/B/Desktop/Tutelacquecal/Base",
layer="griglia_idrologico")
tps<-mask(tps,contorno)
1

See ?raster::interpolate (the examples show the use of thin plate splines).

There are additional interpolation examples at rspatial.org, including a thin plate spline example towards the end of this page: http://www.rspatial.org/analysis/rst/4-interpolation.html

Based on those examples you can perhaps rephrase your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.