Dear list members,
I am currently trying out the new GRASS 6/R-stats interface.
I installed all software today (R-2.1.0, all interfaces, using
GRASS 6.1-CVS).
There is a little problem which I don't understand:
Error in "names<-.default"(`*tmp*`, value = "landcover.orig") :
'names' attribute [1] must be the same length as the vector [0]
# this works:
landcover <- readCELL6sp("geology", cat = FALSE)
lcov <- readCELL6sp("landcover.30m",cat = TRUE)
Error in "names<-.default"(`*tmp*`, value = "landcover.30m") :
'names' attribute [1] must be the same length as the vector [0]
I was inspired by
http://r-spatial.sourceforge.net/xtra/xtra.RHnw.html
and the upcoming article from Roger Bivand in the GRASS Newsletter Vol3.
Was there a change recently which makes category transfer fail?
Best regards
Markus
Markus Neteler <neteler itc it> http://mpa.itc.it
ITC-irst - Centro per la Ricerca Scientifica e Tecnologica
MPBA - Predictive Models for Biol. & Environ. Data Analysis
Via Sommarive, 18 - 38050 Povo (Trento), Italy
Dear list members,
I am currently trying out the new GRASS 6/R-stats interface.
I installed all software today (R-2.1.0, all interfaces, using
GRASS 6.1-CVS).
There is a little problem which I don't understand:
Error in "names<-.default"(`*tmp*`, value = "landcover.orig") :
'names' attribute [1] must be the same length as the vector [0]
I can't replicate this, I'm afraid (R 2.1.0, Linux, sp 0.7-7, spgrass6
0.1-4 (from CVS on sourceforge, GRASS 6.0.0 release). I don't think the sp
or spgrass6 versions make a difference.
Could you say debug(readCELL6sp) and re-run this please - that should show
which line is failing. Once we know that, please check the arguments to
that function for sanity. I don't think it is important, but I'm running
under LANG=en_GB ; export LANG, not UTF8. My current guess is that the
problem is in:
res <- read.asciigrid(tmpfl, colname = vname, proj4string = p4)
where vname is the layer name. If you additionally do
debug(read.asciigrid), it may fail at: names(df) = colname - please see
what is in colname, and if length(colname) is the same as length(df). One
possibility is that there is something amiss in read.asciigrid().
The landcover.orig layer is strange because there are no category labels
at all, so:
system("r.stats -l -q landcover.orig")
11
21
22
23
31
32
41
42
43
51
71
81
82
83
85
91
92
* no data
so the factor gets built without labels:
str(landcover)
Formal class 'SpatialGridDataFrame' [package "sp"] with 6 slots
..@ data :Formal class 'AttributeList' [package "sp"] with 1 slots
.. .. ..@ att:List of 1
.. .. .. ..$ landcover.orig: Factor w/ 17 levels "","","","","",..: NA 15 2 2 2 2 2 2 2 2 ...
..@ grid :Formal class 'GridTopology' [package "sp"] with 3 slots
.. .. ..@ cellcentre.offset: num [1:2] 589995 4913715
.. .. ..@ cellsize : num [1:2] 30 30
.. .. ..@ cells.dim : int [1:2] 634 477
..@ grid.index : int(0)
..@ coords : num [1:2, 1:2] 589995 608985 4913715 4927995
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
..@ bbox : num [1:2, 1:2] 589995 4913715 608985 4927995
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
.. .. ..$ : chr [1:2] "min" "max"
..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
.. .. ..@ projargs: chr "+proj=utm +zone=13 +a=6378206.4 +rf=294.9786982 +no_defs +nadgrids=conus"
suggesting that the function should check for unique labels of the
matching number.
Best wishes,
Roger
# this works:
landcover <- readCELL6sp("geology", cat = FALSE)
lcov <- readCELL6sp("landcover.30m",cat = TRUE)
Error in "names<-.default"(`*tmp*`, value = "landcover.30m") :
'names' attribute [1] must be the same length as the vector [0]
I was inspired by
http://r-spatial.sourceforge.net/xtra/xtra.RHnw.html
and the upcoming article from Roger Bivand in the GRASS Newsletter Vol3.
Was there a change recently which makes category transfer fail?
Best regards
Markus
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
On Tue, May 31, 2005 at 06:53:31PM +0200, Roger Bivand wrote:
On Tue, 31 May 2005, Markus Neteler wrote:
Dear list members,
I am currently trying out the new GRASS 6/R-stats interface.
I installed all software today (R-2.1.0, all interfaces, using
GRASS 6.1-CVS).
There is a little problem which I don't understand:
Error in "names<-.default"(`*tmp*`, value = "landcover.orig") :
'names' attribute [1] must be the same length as the vector [0]
I can't replicate this, I'm afraid (R 2.1.0, Linux, sp 0.7-7, spgrass6
0.1-4 (from CVS on sourceforge, GRASS 6.0.0 release). I don't think the sp
or spgrass6 versions make a difference.
Could you say debug(readCELL6sp) and re-run this please - that should show
which line is failing. Once we know that, please check the arguments to
that function for sanity. I don't think it is important, but I'm running
under LANG=en_GB ; export LANG, not UTF8. My current guess is that the
problem is in:
res <- read.asciigrid(tmpfl, colname = vname, proj4string = p4)
where vname is the layer name. If you additionally do
debug(read.asciigrid), it may fail at: names(df) = colname - please see
what is in colname, and if length(colname) is the same as length(df). One
possibility is that there is something amiss in read.asciigrid().
The landcover.orig layer is strange because there are no category labels
at all, so:
[... took the wrong landuse map, but it doesn't change ...]
library(spgrass6)
Loading required package: rgdal
Loading required package: abind
Loading required package: pixmap
Geospatial Data Abstraction Library extensions to R successfully loaded
Loading required package: sp
`data.frame': 302418 obs. of 1 variable:
$ map: num NA NA NA NA NA NA NA NA NA NA ...
Browse[1]>
debug: grid = GridTopology(c(xllcenter, yllcenter), rep(cellsize, 2),
c(ncols, nrows))
Browse[1]>
debug: SpatialGridDataFrame(grid, data = df, proj4string = proj4string)
Browse[1]>
exiting from: read.asciigrid(tmpfl, colname = vname, proj4string = p4)
Error in "names<-.default"(`*tmp*`, value = "landcover.30m") :
'names' attribute [1] must be the same length as the vector [0]
I don't know if this is already helpful.
Best regards
Markus