spatial analysis - autocorrelation
TRANSCRIPT
-
8/11/2019 Spatial Analysis - Autocorrelation
1/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
1
Spatial Autocorrelation and Geostatistics in RWork axample in R
Part I
1. library(gstat)data(meuse.all)
2. variables: 17
Rows: 164
Variable Level of measurementsample Ordinal x Ordinaly Ordinalcadmium ratiocopper ratiolead ratiozinc ratioelev ratiodist.m Ratio
om Ratioffreq ratiosoil ratiolime Ordinallanduse nominalin.pit nominalin.meuse155 nominalin.BMcD nominal
3. Unit: ppm
4. sort(meuse.all$copper)
[1] 14 16 17 18 18 18 18 19 19 20 20 20 20 20 20 20 20 20 20 21 21 21 21 21 21 21 2121 22 22 22 22 22 22 22 22 22[38] 22 23 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 24 25 25 25 25 25 25 26 2626 26 26 26 27 27 27 27 27 27
-
8/11/2019 Spatial Analysis - Autocorrelation
2/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
2
[75] 27 27 27 29 29 29 29 29 30 30 31 31 31 31 31 32 32 32 32 33 33 34 34 34 35 35 3536 36 36 36 37 37 38 38 38 39[112] 39 39 41 42 45 46 46 47 47 47 47 48 48 49 50 50 51 53 53 55 55 61 63 65 66 67 6868 69 69 72 74 75 75 76 76 77[149] 77 78 80 81 81 85 85 86 88 90 93 95 104 108 117 128
5. zincsum
-
8/11/2019 Spatial Analysis - Autocorrelation
3/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
3
ZincLog10
1
5
2 0
The are values between 100 and 300 with a frequency with a range between 0-50, values
between 300 and 800 with a frequency below 20. The rest of values have a frequency below 5.
7. meuse.all$zinc.1
-
8/11/2019 Spatial Analysis - Autocorrelation
4/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
4
9. cadmium
-
8/11/2019 Spatial Analysis - Autocorrelation
5/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
5
It looks that exists an autocorrelation between the zinc and copper distribution. The spatiallocation of the two metals looks to coexist. There are some outliers but it is not significant sinceit is not a large quantity.
11.
pairs(meuse.all[18:21])
-
8/11/2019 Spatial Analysis - Autocorrelation
6/17
-
8/11/2019 Spatial Analysis - Autocorrelation
7/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
7
Part II
1.
require('sp')coordinates(meuse.all)
-
8/11/2019 Spatial Analysis - Autocorrelation
8/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
8
CEX: The cex parameter of the plot function gives a scale to the symbol of the variable, thus in our casethis parameter has been set as 4.
ASP:When asp is set equal to 1 the distances between points are represented with moreaccuracy on the screen.
MAX: Returns the (parallel) maxima and minima of the input values
According to the Toblers law,variables closer to each othershare similar values. Thus, wecan see that along the riverthe values are more similarand we can suppose that theconcentration of zinc alongthe river have same values as
well.
-
8/11/2019 Spatial Analysis - Autocorrelation
9/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
9
4. hscat(meuse.all$zinc.1~1,meuse.all,(0:15)*100)
Parameters description for function hscat:Width: the width of subsequent distance intervals into which data point pairs are grouped forsemivariance estimates (0:15)*100
Cloud: the area of semi-variogram (range)Data: dataframe where the data are taken
By observing the scatter plot of the variable meuse.all$zinc.1 it is possible to notice a
stronger autocorrelation at low lags with few values. The greater distances are, themore the number of values are. On the other hand, there are more values where thereis a weak correlation with a ratio near to 0. That does not confirm the strong correlationfor the zinc concentration but rather a weak one.However, in the end, we can conclude that at bigger distances between the points, thedifference between the values is more consistent.
-
8/11/2019 Spatial Analysis - Autocorrelation
10/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
10
5. Meuse.all$zinc.1 ~ 1 means that the variable zinc.1data has been assigned as
constant trend to the variogramNP: number of point pairsDIST:average distance of all point pairsGAMMA:actual sample variogram
Tab.1 Variogram(meuse.all$zinc.1~1, meuse.all)LAG NP DIST GAMMA1 60 80.0948 0.035419492 336 164.1146 0.051504253 461 267.7307 0.065669554 529 372.8053 0.086311925 623 478.5473 0.092137956 631 585.6598 0.110496747 664 692.5486 0.108702658 660 795.9618 0.116689059 677 902.8950 0.1228861710 625 1011.8034 0.1262205011 567 1117.9600 0.1356142212 542 1221.2978 0.1167512113 518 1328.9376 0.1283313614 514 1436.9733 0.1137582115 462 1542.2698 0.11416743
v plot(v,v.fit)
distance
s e m i v a r i a n c e
0.05
0.10
500 1000 1500
-
8/11/2019 Spatial Analysis - Autocorrelation
11/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
11
These values for the second Lag are:np DIST gamma
336 164.1146 0.05150425
6. v
-
8/11/2019 Spatial Analysis - Autocorrelation
12/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
12
6.e The average maximum semivariance is point where there not any possiblecorrelation. The comparison between objects start from lag 1 to n lags until itreaches the maximum spatial dataset sample. This point is called sill.
7.
zinc.dir
-
8/11/2019 Spatial Analysis - Autocorrelation
13/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
13
Part III
1. show.vgms()
2.
distance
s e m i v a r i a n c e
0
1
2
3gm(1,"Nug",0)
0.0 1.0 2.0 3.0
gm(1,"Exp",1) gm(1,"Sph",1)
0.0 1.0 2.0 3.0
gm(1,"Gau",1 vgm(1,"Exc",1)
gm(1,"Mat",1)vgm(1,"Ste",1) vgm(1,"Cir",1) vgm(1,"Lin",0)
0
1
2
3gm(1,"Bes",1)
0
1
2
3gm(1,"Pen",1) vgm(1,"Per",1) gm(1,"Wav",1) vgm(1,"Hol",1) gm(1,"Log",1)
0.0 1.0 2.0 3.0
gm(1,"Pow",1)
0
1
2
3vgm(1,"Spl",1)
-
8/11/2019 Spatial Analysis - Autocorrelation
14/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
14
vgm(1, Sph, 300, 0.5)
vm = fit.variogram(v, model = vgm(1, "Sph", 700, 1))
3.plot(v, model = vm)
4.
data(meuse.grid)
5.
## CHANGEdataset frame object AS s patial object
coordinates(meuse.grid)
-
8/11/2019 Spatial Analysis - Autocorrelation
15/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
15
OK prediction, log-ppm Zn
2.2
2.4
2.6
2.8
3.0
3.2
## What is the spatial resolution of the data set?str(meuse.grid)
cellsize : Named num [1:2] 40 40
6. OK
-
8/11/2019 Spatial Analysis - Autocorrelation
16/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
16
OKpredictionvariance, log-ppm Zn^2
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.10
The prediction of high concentration of zinc follows the preview pattern analysis, i.e. thehigh values of zinc are located along the river. The higher the distance from the river, the lowerthe predicted values of zinc concentration.
-
8/11/2019 Spatial Analysis - Autocorrelation
17/17
Spatial Analysis Autocorrelation Gianni Gorgoglione
17
The prediction of variance in the figure above shows how zinc concentration values aredispersed from the predicted values. The lower prediction variance is depicted in that picturewith cooler color as light blue far from the river side except for where the river changes course.