[R-sig-Geo] grids
Roger Bivand
Roger.Bivand at nhh.no
Tue Dec 7 10:17:18 CET 2010
On Mon, 6 Dec 2010, Agnieszka Kaczmarczyk wrote:
> Hello.
> I make grids and Object of class SpatialPixels not are atrributes?
> Pozdrawiam
> Agnieszka
> #data
> setwd("/home/agnieszka/
> Pulpit/dane1")
>> alu <- read.csv("cooral.csv", header = TRUE, sep = ",")
>> coordinates(alu) = ~x+y
>> attributes(alu) = al
> Error: object 'al' not found
You have two problems - one that assigning through attributes() is
absolutely wrong - it assigns to arbitrary old-style class attributes:
m <- "whatever"
attributes(m)
attributes(m) <- list(class="rubbish")
attributes(m)
class(m)
and the second is that there is no object called "al" in your workspace.
It probably doesn't matter, though, as here:
>> alu.sp = spsample(alu, type = "regular", cellsize = c(50,50))
>> gridded(alu.sp) = TRUE
>> summary(alu.sp)
you are creating a SpatialPixels object covering the input point data.
Ask your question again using the built-in meuse data set, please, and
try to let us know what you are trying to do.
Roger
> Object of class SpatialPixels
> Coordinates:
> min max
> x1 4384052 4393102
> x2 5569919 5579319
> Is projected: NA
> proj4string : [NA]
> Number of points: 34028
> Grid attributes:
> cellcentre.offset cellsize cells.dim
> x1 4384077 50 181
> x2 5569944 50 188
>> # promote to SpatialPixelsDataFrame
>> gridded(alu.sp) <- TRUE
>> # creates the full grid
>> alu.sg = as(alu.sp, "SpatialGridDataFrame")
>> summary(alu.sg)
> Error in .subset2(x, i, exact = exact) : subscript out of bounds
> Error in summary(object at data[[1]]) :
> error in evaluating the argument 'object' in selecting a method for
> function 'summary'
>> class(alu.sg)
> [1] "SpatialGridDataFrame"
> attr(,"package")
> [1] "sp"
>>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list