library(leaflet)
library(RColorBrewer)
library(sp)
library(raster)
library(diffeR)
## Loading required package: rgdal
## rgdal: version: 1.4-8, (SVN revision 845)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
## Path to GDAL shared files: C:/Users/GEOMATICS/Documents/R/win-library/3.6/rgdal/gdal
## GDAL binary built with GEOS: TRUE
## Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
## Path to PROJ.4 shared files: C:/Users/GEOMATICS/Documents/R/win-library/3.6/rgdal/proj
## Linking to sp version: 1.4-1
## Loading required package: ggplot2
## Loading required package: reshape2
setwd("C:/Users/GEOMATICS/PR/Final_Project")
CLC2000 <- raster('CLASIFICACION_2000.tif')
CLC2020 <- raster('CLASIFICACION_2020.tif')
pal <- colorFactor(c('#0046C8','#FFB432' , '#cc0013', '#30eb5b', '#225129',
'#d7cdcc'),
c(1, 2, 3, 4, 5, 6), na.color = "transparent")
leaflet() %>% addTiles() %>%
addRasterImage(CLC2000, colors = pal, opacity = 1.0, method="ngb") %>%
addLegend(pal = pal, values = c(1, 2, 3, 4, 5, 6),
title = "Valle del Magdalena LandCover 2000")
## Warning in colors(.): Some values were outside the color scale and will be
## treated as NA
leaflet() %>% addTiles() %>%
addRasterImage(CLC2020, colors = pal, opacity = 1.0, method="ngb") %>%
addLegend(pal = pal, values = c(1, 2, 3, 4, 5, 6),
title = "Valle del Magdalena LandCover 2020")
## Warning in colors(.): Some values were outside the color scale and will be
## treated as NA
comp <- CLC2020 # 2020 Land Cover
ref <- CLC2000 # 2000 Land Cover
ctmatCompRef <- crosstab(comp, ref)
ctmatCompRef
## CLASIFICACION_2000
## CLASIFICACION_2020 0 1 2 3 4 5 6
## 0 535 815 22 2098 1682 217 43
## 1 49 26902 5468 13122 6692 7056 1895
## 2 66 3089 85888 54258 58952 134954 27203
## 3 32 2140 31244 41475 47632 46952 19342
## 4 26 1332 17926 29990 59369 73161 3031
## 5 0 215 44443 19123 23595 96106 9627
## 6 1 175 13671 7838 2510 8991 10857
categoryComponentsPlot(comp = comp, ref = ref, units = "pixels")

differenceMR(comp, ref, eval='original', percent=TRUE)
## Resolution Quantity Exchange Shift Overall
## 1 0.0002694946 20.9136 39.62565 8.636316 69.17557