I have mapped an area using object-based image analysis. This has resulted in 2000 image objects (polygons) that I want to classify based on their properties (spectral, RGB data, shape, size etc.).
I have saved the data as a .csv for use in 'Randomforest' package.
I have assigned "Habitat Level" as one of six factors for each object in the data (1, 2, 3, 4, 5,6). Example of the csv attached.
data used for randomforest, csv
What I want to do is run randomforest to predict a "Habitat_Level" to each of the image objects (Column: OBJECT_ID).
So the result I need will fill the "PREDICTED" column with "Habitat_Level" (generated from random forest) that uses the OBJECT_ID to discriminate between objects.
I have run the randomforest but I don't know how to assign the classification to existing OBJECT_ID
Any advice would be greatly appreciated
Thanks
You need to use the predict
function to generate predictions for each row in your dataset.
It's hard to give some code without seeing the code you've used so far, and a cut of your data, but something like this should work:
data$PREDICTED <- predict(yourmodel, data)