Hello together,

I was wondering how I can solve the following conversion problem of a raster file: when I try to convert the values from the raster (r) from numeric into a factor via as.factor(r) always the error appears: "Error in 1:ncol(r) : argument of length 0".

r <- raster(ncol=5, nrow=5)
values(r) <- 1:ncell(r)
as.factor(r)

Urgently I have to figure out how to convert a numeric raster into a factor raster for a predict() calculation within the raster package.

Every hint is very welcome!

Best,

Stefan

--
********************************************************************
Stefan Schmidt

Abteilung Landschaftsökologie/
Department Computational Landscape Ecology
Helmholtz-Zentrum für Umweltforschung GmbH – UFZ/
Helmholtz Centre for Environmental Research – UFZ
Permoserstraße 15 / 04318 / Leipzig
Phone: +49 341 235 - 1056
Fax: +49 341 235 - 1939
Email: stefan.schm...@ufz.de
WWW: http://www.ufz.de

Sitz der Gesellschaft: Leipzig
Registergericht: Amtsgericht Leipzig, Handelsregister Nr. B 4703
Vorsitzender des Aufsichtsrats: MinDirig Wilfried Kraus
Wissenschaftlicher Geschäftsführer: Prof. Dr. Georg Teutsch
Administrative Geschäftsführerin: Dr. Heike Graßmann

______________________________________________
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.

Reply via email to