Skip to content

Points to raster

3 messages · Raphael Saldanha, Michael Sumner

#
Hi!

Which is the best way to convert a list of points to a raster? Bellow
I have a excerpt from my 'elev' object.

           x       y    elev
239937.9 7658988 407.079
239937.9 7658968 411.561
239937.9 7658948 415.924
239937.9 7658928 415.480
239937.9 7658908 414.896
239937.9 7658888 408.602
239937.9 7658868 402.261
239937.9 7658848 393.956
239937.9 7658828 385.692
239937.9 7658808 379.095
239937.9 7658788 372.509


Thanks in advance,

Raphael Saldanha
saldanha.plangeo at gmail.com
#
The sp and raster packages both have pathways for this.

library(sp)
coordinates(elev) <- c("x", "y")
gridded(elev) <- TRUE

See vignette("sp")

Or, using raster package:

library(raster)
r.elev <- rasterFromXYZ(elev)

In either case, if your coordinates aren't quite regular you'll need
to explore other options, like the 'tolerance' argument to
?SpatialPixelsDataFrame or the 'digits' argument to ?rasterFromXYZ.

Cheers, Mike.

On Fri, Apr 13, 2012 at 12:06 AM, Raphael Saldanha
<saldanha.plangeo at gmail.com> wrote:

  
    
#
Thanks Michael! This is my first approach for dealing with rasters inside R.
On Thu, Apr 12, 2012 at 11:37 AM, Michael Sumner <mdsumner at gmail.com> wrote: