Mapping Slums – Predict slum location using remote sensing data
In this second use case you will learn the basics on how to predict the slum locations using the dataset of Lagos. To achieve this you are introduced to the machine learning algorithm “Random Forrest” which is applied to identify each pixel as slum or no slum.
You will be working with serveral different data types in this example. The datasets are provided here:
Data preparation in QGIS
In this next step you will use the previously prepared data to train the model. This model will later on be applied to predict the prospective location of slums in Lagos. You’ll learn how to create raster point values that correspond to slum or non slum pixels of the image and how to convert them into a .csv-file. This will enable you to continue processing the data in R-Studio.
Running the random forrest model
After you export your dataset, the next step for you is to run the random forrest model on it. The model is a classification and regression method which consists of multiple so called “decision trees”.
In this lesson you’ll apply the previously prepared data on the RF – model in order to get an actual classification which finally indicates wether a pixel of the satellite image is a slum or not. For this classification you’ll use different covariates like the distance to a public school or the access to a public water point. Each of those covariates has a different impact on the classification wether a particular pixel is a slum or not.
Validating the data
The next step in the process is to validate your data. This is very important because thereby you’ll be able to tell how accurate the result can predict a slum in the study site. You will use different kinds of validation on the model in order to have a better accuracy. In detail you will calculate the sensitivity and the specificity of the model as well as the precision of the result.
In case you’re having any trouble during the process you can always use the help section for support, wich will also be briefly described in the lesson.
Code used in this lesson
####### Prediction & Confusion Matrix - train data###### Predit_Train <- predict(Model_Lag_RF, Train_lag) confusionMatrix(Predit_Train, Train_lag$grid_code) # # Prediction & Confusion Matrix - Test data (Ref data)###### Predict_Ref <- predict(Model_Lag_RF, Ref_lag) confusionMatrix(Predict_Ref, Ref_lag$grid_code) ######Diagnostic of predicted probability score InformationValue::sensitivity(Predict_Ref, Ref_lag$grid_code) InformationValue::specificity(Predict_Ref, Ref_lag$grid_code) InformationValue::precision(Predict_Ref, Ref_lag$grid_code) InformationValue::plotROC(Predict_Ref, Ref_lag$grid_code) #Export_model to file####### out.name <- paste0(output_folder,"/RF_model.rds") saveRDS(Model_Lag_RF,out.name)
Click the ‘Submit’ Button to rate this topic.