[GRASS-user] Natural breaks classification
Luigi Ponti
lponti at inbox.com
Wed May 16 16:04:54 EDT 2012
On 16/05/2012 21:10, Luigi Ponti wrote:
> On 16/05/2012 20:55, Salvatore Mellino wrote:
>> I'm trying but I receive an error.
>>
>> 1. In R I started the libraries spgarass6 and classInt
>> 2. I imported the DTM in R using DTM<-
>> readRAST6("DTM at mapset", ignore.stderr=TRUE)
>> 3. I used the command DTM_class<- classIntervals(DTM,
>> n=5, style="fisher") and I received the error
>>
>> Error in classIntervals(DTM, n = 5, style = "fisher") :
>> var is not numeric
>
> I do not recall exactly, but it may be that classIntervals does not
> have a method for spatial data frames (i.e. the output of readRAST6).
> One thing I would try to get the breaks anyway, is a regular R
> data.frame, for example:
>
> DTM.df <- as.data.frame(DTM)
> DTM_class <- classIntervals(DTM.df, n=5, style="fisher")
>
I am replying to myself as I may have omitted part of the answer -- my
apologies. Start the same way:
DTM.df <- as.data.frame(DTM)
then get variable names:
names(deltaYieldVector.df)
then use the variable of interest (altitude, I guess):
DTM_class <- classIntervals(DTM.df$varOfInterest, n=5, style="fisher")
This should work; we were feeding a data.frame as input to
classIntervals, whereas a variable is needed (e.g. one of the variables
in the data.frame).
Let me know how it goes.
Kind regards,
Luigi
More information about the grass-user
mailing list