[R-sig-Geo] Errore in sprintf(fmt, ...) ?
Roger Bivand
Roger.Bivand at nhh.no
Sat Dec 2 16:19:10 CET 2006
On Sat, 2 Dec 2006, Massimo Di Stefano wrote:
> Roger:
>
> This is the log,
>
> > library(spgrass6)
> Carico il pacchetto richiesto: sp
> Carico il pacchetto richiesto: maptools
> Carico il pacchetto richiesto: foreign
> Carico il pacchetto richiesto: rgdal
> Geospatial Data Abstraction Library extensions to R
> successfully loaded
> > library(cluster)
> > sessionInfo()
> R version 2.4.0 (2006-10-03)
> powerpc-apple-darwin8.7.0
>
> locale:
> it_IT/it_IT/it_IT/C/it_IT/it_IT
>
> attached base packages:
> [1] "methods" "stats" "graphics" "grDevices"
> "utils" "datasets"
> [7] "base"
>
> other attached packages:
> cluster spgrass6 rgdal maptools foreign sp
> "1.11.2" "0.3-3" "0.5-1" "0.6-3" "0.8-18" "0.9-4"
> > gc()
> used (Mb) gc trigger (Mb) max used (Mb)
> Ncells 408935 11.0 597831 16 531268 14.2
> Vcells 320324 2.5 786432 6 472905 3.7
> > gmeta6 <- gmeta6()
> > x <-
> readFLOAT6sp(c("er","crosc","longc","slope","profc","minic","maxic"))
> Warning messages:
> 1: perl = TRUE è implementato solo nei locale UTF-8
> 2: perl = TRUE è implementato solo nei locale UTF-8
> 3: perl = TRUE è implementato solo nei locale UTF-8
> 4: perl = TRUE è implementato solo nei locale UTF-8
> 5: perl = TRUE è implementato solo nei locale UTF-8
> 6: perl = TRUE è implementato solo nei locale UTF-8
> 7: perl = TRUE è implementato solo nei locale UTF-8
Nowadays I would suggest readRAST6() instead of readFLOAT6sp(), because it
uses r.out.bin rather than r.out.arc from GRASS. The perl=TRUE warnings
seems to be coming from string comparison somewhere inside a function
called by readFLOAT6sp(), I don't think they are the problem.
> > gc()
> used (Mb) gc trigger (Mb) max used
> (Mb)
> Ncells 418204 11.2 741108 19.8 699974
> 18.7
> Vcells 22643234 172.8 191414408 1460.4 238993684
> 1823.4
> > morph <- data.frame(cbind(x$er, x$crosc, x$longc,
> x$slope, x$profc, x$minic, x$maxic))
morph <- as(x, "data.frame")
str(morph) # look inside morph
summary(morph)
sapply(morph, function(x) any(!is.finite(x)))
# check morph for NAs etc.
> > gc()
> used (Mb) gc trigger (Mb) max used
> (Mb)
> Ncells 418451 11.2 741108 19.8 699974
> 18.7
> Vcells 46682176 356.2 153131526 1168.4 238993684
> 1823.4
> <er, x$crosc, x$longc, x$slope/max(x$slope), x$profc,
> x$minic, x$maxic))
> > gc()
> used (Mb) gc trigger (Mb) max used
> (Mb)
> Ncells 418453 11.2 741108 19.8 699974
> 18.7
> Vcells 46682176 356.2 137841862 1051.7 238993684
> 1823.4
> > names(morph) <-
> c("er","crosc","longc","slope_n","profc","minic","maxic")
> > gc()
> used (Mb) gc trigger (Mb) max used
> (Mb)
> Ncells 418456 11.2 741108 19.8 699974
> 18.7
> Vcells 46682180 356.2 137841862 1051.7 238993684
> 1823.4
> > morph.clara <- clara(morph, k=5, stand=F)
> Errore in clara(morph, k = 5, stand = F) :
> Observations
> 1929241,1931311,1933381,1935451,1937521,1939591,1941661,1943731,1945801,1947871,1949941,1952011,1954081,1956151,1958221,1960291,1962361,1964431,1966501,1968571,1970641,1972711,1974781,1976851,1978921,1980991,1983061,1985131,1987201,1989271,1991341,1993411,1995481,1997551,1999621,2001691,2003761,2005831,2007901,2009971,2012041,2014111,2016181,2018251,2020321,2022391,2024461,2026531,2028601,2030671,2032741,2034811,2036881,2038951,2041021,2043091,2045161,2047231,2049301,2051371,2053441,2055511,2057581,205965
> 1,2061721,2063791,2065861,2067931,2070001,2072071,2074141,2076211,2078281,2080351,2082421,2084491,2086561,2088631,2090701,2092771,2094841,2096911,2098981,2101051,2103121,2105191,2107261,2109331,2111401,2113471,2115541,2117611,2119681,2121751,2123821,21258
> 91,2127961,2130031,2132101,2134171,2136241,2138311,2140381,2142451,2144521,2146591,2148661,2150731,2152801,2154871,2156941,2159011,2161081,2163151,2165221,2167291,2169361,2171431
> > traceback()
> 2: stop(ngettext(length(i), sprintf("Observation %d
> has", i[1]),
> sprintf("Observations %s have", paste(i,
> collapse = ","))),
> " *only* NAs --> omit for clustering")
> 1: clara(morph, k = 5, stand = F)
>
> is this log usefool ?
Yes, I think the problem is firstly that there are NAs in morph, and then
that the string listing the row numbers of the NAs exceeds 8K characters
(your earlier message had: Errore in sprintf(fmt, ...) : La lunghezza
della stringa eccede la dimensione del buffer di 8192)
So try clara on morph once you have omitted the NAs. If the NAs are for
all variables in a row, coercing from SpatialGridDataFrame to
SpatialPixelsDataFrame will work, if only some, you need to set the whole
row to NA, coerce, cluster, add the clara results to the
SpatialPixelsDataFrame, coerce back to SpatialGridDataFrame, then back to
GRASS.
Once this is resolved, please post back to the list as well as to me, NAs
do happen, expecially in geomorphometrics, for example around the edges
where the filter is not fully within the window and/or mask.
Best wishes,
Roger
> thanks a lot!
> Massimo.
>
> Il giorno 02/dic/06, alle ore 11:16, Roger Bivand ha
> scritto:
>
> On Fri, 1 Dec 2006, Massimo Di Stefano wrote:
>
> Massimo:
>
> Two deep breaths, it'll work out. Memory may well be a
> problem, but we
> can't see what is going on without
>
> 1) sessionInfo() for your platform with the packages
> loaded
>
> 2) traceback() after the problem arises
>
> 3) do not run this as a script - run it line by line,
> so that you can
> check things step by step. Run gc() - garbage
> collector - manually, and
> stay in control as much as possible.
>
> Roger
>
> hi,
> i'm trying to perform a clustering on a dem (50x50 km
> res=20m)
> is this is the code:
>
>
> require(spgrass6)
>
> require(cluster)
>
> gmeta6 <- gmeta6()
>
> x <-
> readFLOAT6sp(c("er","crosc","longc","slope","profc","minic","maxic"))
>
> morph <- data.frame(cbind(x$er, x$crosc, x$longc,
> x$slope, x$profc, x$minic, x$maxic))
>
> morph <- data.frame(cbind(x$er, x$crosc, x$longc,
> x$slope/max(x$slope), x$profc, x$minic, x$maxic))
>
> names(morph) <-
> c("er","crosc","longc","slope_n","profc","minic","maxic")
>
> print("perform the clustering")
>
> morph.clara <- clara(morph, k=5, stand=F)
>
> x$morph_class <- morph.clara$clustering
>
> print("send result back to GRASS")
>
> rast.put6(x,"morph", zcol="morph_class")
> ....
> ......
> but during:
> "perform the clustering"
>
> i'had this error:
>
> Errore in sprintf(fmt, ...) : La lunghezza della
> stringa eccede la dimensione del buffer di 8192
> Inoltre: Warning messages:
> 1: perl = TRUE è implementato solo nei locale UTF-8
> 2: perl = TRUE è implementato solo nei locale UTF-8
> 3: perl = TRUE è implementato solo nei locale UTF-8
> 4: perl = TRUE è implementato solo nei locale UTF-8
> 5: perl = TRUE è implementato solo nei locale UTF-8
> 6: perl = TRUE è implementato solo nei locale UTF-8
> 7: perl = TRUE è implementato solo nei locale UTF-8
> 8: La stringa di caratteri verrà probabilmente
> troncata
> Esecuzione interrotta
>
> if i try the same code on a subregion of my data
> (about 20x20 km res=20), it works very fine!
> but for a large region i've this error :-(
>
> obviously i think that is a memory problem, right ?
> (i'm working with a notebook PPC-1.33-512ram)
> my data are : 7 raster-map on a region of about 50X40
> km at a resolution of 20m.
> is there some wolkaround about the memory problems?
>
> an other question is:
> what is this :
> Warning messages:
> 1: perl = TRUE è implementato solo nei locale UTF-8
> 2: perl = TRUE è implementato solo nei locale UTF-8
> 3: perl = TRUE è implementato solo nei locale UTF-8
> 4: perl = TRUE è implementato solo nei locale UTF-8
> 5: perl = TRUE è implementato solo nei locale UTF-8
> 6: perl = TRUE è implementato solo nei locale UTF-8
> 7: perl = TRUE è implementato solo nei locale UTF-8
>
> is it about this line of the code :
>
> morph.clara <- clara(morph, k=5, stand=F)
> i have an F > false
>
>
> frustated for this error, to day i buy a 1 GB memory
> slot for my laptop
> now it have 1,28GB instead the old 512, but i've the
> same error :-(
> damn!damn!....how can i do?
> repeat for a little area (about 20X20 km and res=20m)
> it work fine!
> have you any suggestion?
> is ther a method for look if this error depend from my
> ram or other....?
> thanks foe any suggestion!
> i need your help.
> thanks.
> Massimo
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> 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