[R-sig-Geo] help with spatial interpolation
Fernando González Cortés
fernando.gonzalez at iver.es
Wed Sep 7 08:20:35 CEST 2005
I think I've solved the problem. I used the maptools library to read the
points from a shapefile and the fields library to obtain the grid. Here is
the script:
library(maptools)
points <- read.shape("points2d")
x <- array(0, c(length(points$Shapes),2))
for (i in 1:length(points$Shapes)) { x[i,1] <-
points$Shapes[[i]]$verts[,1] }
for (i in 1:length(points$Shapes)) { x[i,2] <-
points$Shapes[[i]]$verts[,2] }
y = points$att.data[[2]]
library(fields)
fit <- Tps(x, y)
fit.prediction <- predict.se(fit)
out <- predict.surface(fit, nx=1000, ny=1000)
png()
par(mai=c(0,0,0,0))
image(out, axes=FALSE, col=gray((100 - 0:100) / 100))
dev.off()
Bye
----- Original Message -----
From: "Rick Reeves" <reeves at nceas.ucsb.edu>
To: "'Fernando González Cortés'" <fernando.gonzalez at iver.es>
Sent: Wednesday, September 07, 2005 1:35 AM
Subject: RE: [R-sig-Geo] help with spatial interpolation
Fernando:
The shapefiles package is a likely candidate.
Regards,
Rick Reeves
Scientific Programmer/Analyst
National Center for Ecological Analysis and Synthesis (NCEAS)
University of California, Santa Barbara CA 93101
805 892 2534
reeves at nceas.ucsb.edu
-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Fernando González
Cortés
Sent: Monday, September 05, 2005 4:43 AM
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] help with spatial interpolation
Hello,
I have the following problem: I have a set of 3d points irregularly
spaced. I have to obtain a grid with the interpolated values between the
points and I have to use a spline interpolation. I have seen some R packages
that perform some kind of interpolation but I don't know which one should I
use. Can anyone help me to find the right one?
I just used the 'Tps' method of the 'fields' package and i've obtained a
nice graphic. Does anyone knows how to export the result of the
interpolation to be used in a GIS application?
Thanks in advance
Fernando
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list