[R-sig-Geo] raster::raster from SpatialPixelsDataFrame object
Agustin Lobo
alobolistas at gmail.com
Fri Jan 24 09:34:10 CET 2014
Thanks.
It would be good having this documented in the help page of raster.
The closest is for
## S4 method for signature 'SpatialPixels'
raster(x, layer=1, values=TRUE)
which does not provide any clue for the case of SpatialPixelsDataFrame objects.
Another suggestion: a syntax similar to the one in rasterize() would
make sense for consistency,
ie. having the following
r <- raster(x=m, field="dist")
as a valid command also would be helpful for the user (similar syntax
for similar tasks is the only way to remember a language)
Agus
On Thu, Jan 23, 2014 at 4:36 PM, Edzer Pebesma
<edzer.pebesma at uni-muenster.de> wrote:
>
>
> On 01/23/2014 04:17 PM, Agustin Lobo wrote:
>> In order to convert a SpatialPixelsDataFrame object "m" into a raster I just do
>> data(meuse.grid)
>> m = SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")], data = meuse.grid)
>> m at data <- data.frame(name="A",m at data)
>> r <- raster(m)
>>
>> but the actual values are taken from the first column as I'm not
>> selecting the numeric field in
>> the table.
>> Is there a way to select the field as in rasterize?
>
> you mean, like in:
>
> r <- raster(m[3])
>
> or
>
> r <- raster(m["ffreq"])
>
> ?
>
>>
>> r2 <- rasterize(x=m,y=r, field="dist")
>>
>> It would make sense doing this in just one command.
>>
>> Thanks
>>
>> Agus
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> --
> Edzer Pebesma
> Institute for Geoinformatics (ifgi), University of Münster
> Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251
> 83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
More information about the R-sig-Geo
mailing list