On 16/12/2013 15:14, Lauria, Valentina wrote:
Dear List members,
I am trying to map the habitat suitability of Nephrops and one of my predictor
is a categorical variable.
However when I utilised the command "as.factor" (before to create my rasters stack) I get
the error message "Error in 1:ncol(r) : argument of length 0".
Could anyone help me?
Yes. This is a bug in package raster. So please follow the posting
guide and report to the maintainer, with the 'at a minimum' information
missing here (a crucial part being the version of raster).
Using 1:ncol() is bad practice (seq_len is designed for that purpose),
but the raster maintainer misuses it ca 100x.
r4 <-
raster("C:/POSTDOC/NEPHROPS_Habitat_Mapping/NEPHROPS_HabMod_PAPER1/Scotland/IN_eunis_sed.tif")
plot(r4)
is.factor(r4)
[1] TRUE
as.factor(r4)
class : RasterLayer
dimensions : 250, 413, 103250 (nrow, ncol, ncell)
resolution : 0.01484784, 0.01484784 (x, y)
extent : -7.774709, -1.642552, 54.95371, 58.66567 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
data source :
C:\POSTDOC\NEPHROPS_Habitat_Mapping\NEPHROPS_HabMod_PAPER1\Scotland\IN_eunis_sed.tif
names : IN_eunis_sed
values : 1, 6 (min, max)
attributes :
Error in 1:ncol(r) : argument of length 0
levels(r4)
[[1]]
ID OBJECTID Value Count sediment
0 1 1 2716 R
1 2 2 2249 CS
2 3 3 2647 MS
3 4 4 6819 M
4 5 5 889 MXS
5 6 6 3647 S
Thank you very much in advance.
Best Regards,
Valentina
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
Brian D. Ripley, rip...@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.