[R-sig-Geo] Decision tree classification of satellite image in R
Jonathan Greenberg
jgrn at illinois.edu
Tue May 6 17:52:57 CEST 2014
Anusheema:
The first error is because you didn't specify an out filename (it
needs to be a character).
Re: the second error -- is there a predict.R_Weka_classifier_interface
(or something along those lines) in that package? For predict to
work, you need a predict.* statement available.
You might want to swap in a randomForest for the classifier you are
using, at least to begin with -- randomForest does work properly with
raster's predict() statement.
--j
On Tue, May 6, 2014 at 1:37 AM, Anusheema Chakraborty
<anusheema at gmail.com> wrote:
> Hi!
>
> I am trying to classify satellite image in R using RWeka classifier,
> J48. I have a CSV file with the classes required, and raster data
> loaded in R. I am able to make the tree, however, I am not able to use
> the same tree to classify my satellite image.
>
> Here's how it goes.
>
> inputfile=read.csv("E://R/Trial/naini.CSV")
> m1 <- J48(Class~B1+B2+B3+B4+B5+B7, data = inputfile)
> if(require("party", quietly = TRUE)) plot(m1)
> raster<- brick("merge.tif")
> plotRGB(raster, 4, 3, 2, stretch="hist")
>
> And then I am attempting to use the tree generated to classify my
> satellite image, but I keep getting errors.
>
> predict (test_new, J48, filename=out_classify,
> progress='text',format='GTiff', datatype='FLT4S', type='response',
> overwrite=TRUE)
> Error in trim(filename) : error in evaluating the argument 'x' in
> selecting a method for function 'trim': Error: object 'out_classify'
> not found
>
> And if I change the arguments, this is what I get. I am not sure how
> to proceed from this point forward.
>
> predict (J48, test_new, filename=out_classify,
> progress='text',format='GTiff', datatype='FLT4S', type='response',
> overwrite=TRUE)
> Error in UseMethod("predict") : no applicable method for 'predict'
> applied to an object of class "c('R_Weka_classifier_interface',
> 'R_Weka_interface')"
>
> I am new to R, so I might take a while to decipher your answers. Any
> help would be greatly appreciated!
>
> Thanks!
>
>
> Best,
> Anusheema.
>
>
>
> --
> Regards
>
> Anusheema Chakraborty
> Ph.D. Scholar
> Department of Natural Resources, TERI University
> 10, Institutional Area, Vasant Kunj, New Delhi - 110070
> Website: www.teriuniversity.ac.in
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL 61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype: jgrn3007
More information about the R-sig-Geo
mailing list