[R-sig-Geo] Adding values to a raster

2011-09-17 Thread Tara Bridwell
I have a dataset that consists of point coordinates and values associated with the points.  I want to be able to grid the values, and then do calulations using the values using the various raster functions.  I am, however, finding this difficult to do.  I have tried a number of functions including

Re: [R-sig-Geo] Converting spatialPointsDataFrame into ppp

2011-09-17 Thread GodinA
Thank you very much for this quick reply Dr. Bivand. I am taking good notes of your suggestions. I'm a little concern about your comments that my data are not a marked point process and would like to verify with you a few points. You are correct that my points - the catch positions are

Re: [R-sig-Geo] Adding values to a raster

2011-09-17 Thread Robert J. Hijmans
Tara, I think you need to 'rasterize' function library(raster) r - raster(ncol=10, nrow=10) x - c(-25, -148, 46, 23, 0, -69) y - c(-45, 30, 20, -10, 50, -7) value - c(1, 2, 3, 4, 5, 6) # you can do this: r1 - rasterize(cbind(x, y), r, value) plot(r1) # or sp -

Re: [R-sig-Geo] Jenks classification for raster representation

2011-09-17 Thread Robert J. Hijmans
Arnaud, You can (directly) do the same with Raster* objects what Roger did with sp objects: library(raster) t-raster(ncol = 10, nrow = 10) t[1:2,] - seq(1,10,1) t[3:5,1:5] - seq(1,5,1) t[6:8,6:10] - seq(6,10,1) t[9:10,] - seq(1,10,1) plot(t) library(classInt) zClass - classIntervals(values(t),

[R-sig-Geo] How to efficiently clip large grids/raster with polygons?

2011-09-17 Thread Ariel Ortiz-Bobea
Hello everyone, I've been exploring ways to clip a grid/raster with a polygon/shape file in R but what I have seen so far seems more suited for relatively fine grids and large polygons (e.g. many grids fall within each polygon). I'm confronted with a relatively coarse data grid for the US (0.3

Re: [R-sig-Geo] Jenks classification for raster representation

2011-09-17 Thread Tara Bridwell
Thank you Robert. That worked perfectly. I had been missing the proper structure in using the rasterize function. Tara On Sat, Sep 17, 2011 at 5:42 PM, Robert J. Hijmans r.hijm...@gmail.com wrote: Arnaud, You can (directly) do the same with Raster* objects what Roger did with sp objects:

Re: [R-sig-Geo] [raster] a railroad, a raster with a different value on each side of it

2011-09-17 Thread Robert J. Hijmans
Nice problem: library(raster) cds1 - rbind(c(-100,91), c(-140,15), c(-10, 40), c(-140,-91)) lines - SpatialLines(list(Lines(list(Line(cds1)), 1))) r - raster(ncols=50, nrows=45, xmx=10) r - rasterize(lines, r) rc - rowColFromCell(r, cellFromXY(r, rasterToPoints(r))) west - tapply(rc[,2], rc[,1],