Papadopoulos Alexandros January 12, 2018papadopoulosalex.com/products/r/dem/knit_dem_comp.pdf ·...

6
dem_comparison Papadopoulos Alexandros January 12, 2018 R Markdown First thing first, package ‘raster’ in needed for geographical data analysis and modeling. library(raster) ## Warning: package raster was built under R version 3.3.3 ## Warning: package sp was built under R version 3.3.3 With the ‘raster’ library tif layer can create RasterLayers. In this case f and h parameters are the DEMs made by us and p is reference DEM we want to compare them to. f <- S1A_20151217_20151229.tif DEM_s1_20152117_20151229 = raster(f) h <- S1A_0170209_20170221.tif DEM_s1_20170209_20170221 = raster(h) p <- Rio-Patra_Ktim_5m_UTM34N.tiff DEM_ktimatologiou0 = raster(p) In order to make pixel by pixel computations, the DEMs have to be of the same extent and resolution. The ‘extent’ function returns the Extent of one object (here one of the made DEMs because it is smaller than the reference). ‘Crop’ returns the geographic subset of the reference object, as specified by the Extent object. Finally, ‘projectRaster’ projects the values of the made DEMs to a new object with the projection and resolution of the reference DEM. The following three plots demonstrate the topography of the are for each DEM. e <- extent(DEM_s1_20152117_20151229) DEM_ktimatologiou <- crop(DEM_ktimatologiou0, e) DEM_s1_20152117_20151229_asKtim <- projectRaster(DEM_s1_20152117_20151229, DEM_ktimatologiou) DEM_s1_20170209_20170221_asKtim <- projectRaster(DEM_s1_20170209_20170221, DEM_ktimatologiou) par(mfrow=c(1,3)) plot(DEM_ktimatologiou, main = "DEM_ktimatologiou") plot(DEM_s1_20152117_20151229_asKtim, main = "DEM_s1_20152117_20151229") plot(DEM_s1_20170209_20170221_asKtim, main = "DEM_s1_20170209_20170221") 1 PAPADOPOULOSALEX.COM

Transcript of Papadopoulos Alexandros January 12, 2018papadopoulosalex.com/products/r/dem/knit_dem_comp.pdf ·...

Page 1: Papadopoulos Alexandros January 12, 2018papadopoulosalex.com/products/r/dem/knit_dem_comp.pdf · dem_comparison Papadopoulos Alexandros January 12, 2018 R Markdown Firstthingfirst,package‘raster’inneededforgeographicaldataanalysisandmodeling.

dem_comparisonPapadopoulos Alexandros

January 12, 2018

R Markdown

First thing first, package ‘raster’ in needed for geographical data analysis and modeling.library(raster)

## Warning: package 'raster' was built under R version 3.3.3

## Warning: package 'sp' was built under R version 3.3.3

With the ‘raster’ library tif layer can create RasterLayers. In this case f and h parameters are the DEMsmade by us and p is reference DEM we want to compare them to.f <- 'S1A_20151217_20151229.tif'DEM_s1_20152117_20151229 = raster(f)

h <- 'S1A_0170209_20170221.tif'DEM_s1_20170209_20170221 = raster(h)

p <- 'Rio-Patra_Ktim_5m_UTM34N.tiff'DEM_ktimatologiou0 = raster(p)

In order to make pixel by pixel computations, the DEMs have to be of the same extent and resolution.The ‘extent’ function returns the Extent of one object (here one of the made DEMs because it is smallerthan the reference). ‘Crop’ returns the geographic subset of the reference object, as specified by the Extentobject. Finally, ‘projectRaster’ projects the values of the made DEMs to a new object with the projectionand resolution of the reference DEM. The following three plots demonstrate the topography of the are foreach DEM.e <- extent(DEM_s1_20152117_20151229)DEM_ktimatologiou <- crop(DEM_ktimatologiou0, e)DEM_s1_20152117_20151229_asKtim <- projectRaster(DEM_s1_20152117_20151229, DEM_ktimatologiou)DEM_s1_20170209_20170221_asKtim <- projectRaster(DEM_s1_20170209_20170221, DEM_ktimatologiou)

par(mfrow=c(1,3))plot(DEM_ktimatologiou, main = "DEM_ktimatologiou")plot(DEM_s1_20152117_20151229_asKtim, main = "DEM_s1_20152117_20151229")plot(DEM_s1_20170209_20170221_asKtim, main = "DEM_s1_20170209_20170221")

1

PAPADOPOULOSALE

X.COM

Page 2: Papadopoulos Alexandros January 12, 2018papadopoulosalex.com/products/r/dem/knit_dem_comp.pdf · dem_comparison Papadopoulos Alexandros January 12, 2018 R Markdown Firstthingfirst,package‘raster’inneededforgeographicaldataanalysisandmodeling.

566000 569000 572000

4225

000

4230

000

4235

000

4240

000

DEM_ktimatologiou

200

400

600

800

1000

1200

566000 569000 572000

4225

000

4230

000

4235

000

4240

000

DEM_s1_20152117_20151229

0

200

400

600

800

1000

1200

1400

566000 569000 572000

4225

000

4230

000

4235

000

4240

000

DEM_s1_20170209_20170221

0

200

400

600

800

1000

1200

Then the comparison between made DEMs and reference DEM in made by their subtraction. Then, two plotsshow the differences between each made DEM and the reference one. Green pixels show that the referenceDEM had higher values that the made one and red pixels show that the reference DEM had smaller valuesthat made one. Plotting spacially their differences patterns may be identified, in this case the DEMs shouldbe re-evaluated and find the cause for the patterns.diff2015 = DEM_ktimatologiou - DEM_s1_20152117_20151229_asKtimdiff2017 = DEM_ktimatologiou - DEM_s1_20170209_20170221_asKtim

par(mfrow=c(1,2))plot(diff2015, main = "Diff=DEM_ktimatologiou - DEM_s1_20152117_20151229")plot(diff2017, main = "Diff=DEM_ktimatologiou - DEM_s1_20170209_20170221")

2

PAPADOPOULOSALE

X.COM

Page 3: Papadopoulos Alexandros January 12, 2018papadopoulosalex.com/products/r/dem/knit_dem_comp.pdf · dem_comparison Papadopoulos Alexandros January 12, 2018 R Markdown Firstthingfirst,package‘raster’inneededforgeographicaldataanalysisandmodeling.

566000 569000 572000

4226

000

4230

000

4234

000

Diff=DEM_ktimatologiou − DEM_s1_20152117_20151229

−300−200−1000100200

566000 569000 57200042

2600

042

3000

042

3400

0

Diff=DEM_ktimatologiou − DEM_s1_20170209_20170221

−300−200−1000100200

Usefuls histograms can also be generated. The first three represent the probability of values for each DEM.The other two histograms show the probability of difference between the reference and the made DEMs.par(mfrow=c(1,3))hist(DEM_ktimatologiou, prob=T, main="DEM_ktimatologiou", xlab="")hist(DEM_s1_20152117_20151229_asKtim, prob=T, main="DEM_s1_20152117_20151229_asKtim", xlab="")hist(DEM_s1_20170209_20170221_asKtim, prob=T, main="DEM_s1_20170209_20170221_asKtim", xlab="")

3

PAPADOPOULOSALE

X.COM

Page 4: Papadopoulos Alexandros January 12, 2018papadopoulosalex.com/products/r/dem/knit_dem_comp.pdf · dem_comparison Papadopoulos Alexandros January 12, 2018 R Markdown Firstthingfirst,package‘raster’inneededforgeographicaldataanalysisandmodeling.

DEM_ktimatologiouD

ensi

ty

0 400 800 1200

0.00

000.

0005

0.00

100.

0015

0.00

200.

0025

DEM_s1_20152117_20151229_asKtim

Den

sity

0 500 1000 1500

0.00

000.

0005

0.00

100.

0015

0.00

200.

0025

0.00

30

DEM_s1_20170209_20170221_asKtim

Den

sity

0 500 1000

0.00

000.

0005

0.00

100.

0015

0.00

20par(mfrow=c(2,1))hist(diff2015, prob=T, breaks=40,main="Diff=DEM_ktimatologiou - DEM_s1_20152117_20151229", xlab="")hist(diff2017, prob=T, breaks=40,main="Diff=DEM_ktimatologiou - DEM_s1_20170209_20170221", xlab="")

4

PAPADOPOULOSALE

X.COM

Page 5: Papadopoulos Alexandros January 12, 2018papadopoulosalex.com/products/r/dem/knit_dem_comp.pdf · dem_comparison Papadopoulos Alexandros January 12, 2018 R Markdown Firstthingfirst,package‘raster’inneededforgeographicaldataanalysisandmodeling.

Diff=DEM_ktimatologiou − DEM_s1_20152117_20151229

Den

sity

−300 −200 −100 0 100 200

0.00

0

Diff=DEM_ktimatologiou − DEM_s1_20170209_20170221

Den

sity

−400 −300 −200 −100 0 100 200

0.00

0

With the code underneath the standard deviation of the differences (reference - made DEMs) is computed:2015 case = 50.611

2017 case = 43.273standard_deviation15 = sd(c(as.matrix(diff2015)),na.rm=T)standard_deviation17 = sd(c(as.matrix(diff2017)),na.rm=T)

Root Mean Square Error (RMSE) between sim and obs, in the same units of sim and obs, with treatment ofmissing values. RMSE gives the standard deviation of the model prediction error. A smaller value indicatesbetter model performance.library(hydroGOF)

## Warning: package 'hydroGOF' was built under R version 3.3.3

## Warning: package 'zoo' was built under R version 3.3.3DEM_1_matrix = c(as.matrix(DEM_ktimatologiou))DEM_2_matrix = c(as.matrix(DEM_s1_20152117_20151229_asKtim))rmseA = rmse(DEM_1_matrix,DEM_2_matrix)rmseA

## [1] 57.67353DEM_1_matrix = c(as.matrix(DEM_ktimatologiou))DEM_2_matrix = c(as.matrix(DEM_s1_20170209_20170221_asKtim))rmseB = rmse(DEM_1_matrix,DEM_2_matrix)rmseB

5

PAPADOPOULOSALE

X.COM

Page 6: Papadopoulos Alexandros January 12, 2018papadopoulosalex.com/products/r/dem/knit_dem_comp.pdf · dem_comparison Papadopoulos Alexandros January 12, 2018 R Markdown Firstthingfirst,package‘raster’inneededforgeographicaldataanalysisandmodeling.

## [1] 54.91381

6

PAPADOPOULOSALE

X.COM