Partially answering myself:
This is what I've done until now:

xter <-
readOGR(dsn="/media/Transcend/PROVI/MARICEL2/x_terRiverBasin",layer="x_ter")
> class(xter)
[1] "SpatialLinesDataFrame"
attr(,"package")
[1] "sp"

xterp <- coordinates(xter)
xterp <- sapply(xterp, function(x) do.call("rbind", x))
xterp <- do.call("rbind",xterp)

as told by Roger.

Now:
require(raster)
r <- raster("test.tif")
xterpdata <- xyValues(r,xterp)
xterp2 <- data.frame(utmx=xterp[,1], utmy=xterp[,2], NO3_2007=xterpdata)
coordinates(xterp2) <- c("utmx", "utmy")

So I get to step 2, but don't see how to convert from the points
to the lines again (to get xterl). The problem is that when I did:
xterp <- sapply(xterp, function(x) do.call("rbind", x))
xterp <- do.call("rbind",xterp)

I lost the IDs of the lines. So I would need to keep the IDs of the lines
for each point in the result of
coordinates() to be able of going back to the lines once I've put the raster
values in the data slot of the xterp

I'll keep on, but any help would be much appreciated.

Agus

2010/1/29 Agustin Lobo <alobolistas@gmail.com>

> Hi!
>
> My goal is to colorcode a river network according to the values of
> a raster map (which comes from an interpolation). The spatial lines are
> imported
> from a shapefile. The raster could be imported or I could run the
> interpolation in R.
>
> As what I'm planing could be rather involved, I prefer asking before:
>
> 1. Convert spatial lines to spatial points as discussed earlier this week.
> 2. Overlay points on the raster and get the values for the points in a
> Spatial Points Data Frame
> 3. Convert the Spatial Points Data Frame into Spatial Lines Data Frame
> 4. writeOGR() to shapefile.
>
> The main question is: is the data frame of the points going to be
> transferred to the lines
> at step 3?
>
> THnaks
>
> Agus
>

	[[alternative HTML version deleted]]

