Plots2GE: Georeferencing custom R plots into Google Earth

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/Plots2GE.R

Description

Plots2GE: Places PNG R plots on Google Earth, as KML files.

Usage

1
Plots2GE(data, center, nesting = 0, customfun, goo = "Plots2GE.kml", testrun = FALSE)

Arguments

data

Dataset used for producing the plots (will be the input of your customfun, see below).

center

Matrix including the longitude(s) and latitude(s) of point(s) where to locate plots (decimal degrees). Must correspond to "data", with same number and ordering of observations.

nesting

Location-specific identifier, used to group the data into location-specific subsets and produce location specific plots. Must correspond to "data", with same number and ordering of observations.

customfun

User-defined function to produce the plots, see details.

goo

Name of the KML file to that will be saved into the working directory (use getwd() to find it).

testrun

Diagnositc mode. T (will run only at the screen, for checking purposes) or F (will produce actual plots as png files for Google Earth).

Details

The user needs to declare a function where the input is the "data" matrix, and the output is a plot. Plots2GE will then apply this function to any location-specific subset (the locations being defined using the "nesting" parameter). Any function is possible, just keep in mind that Plots2GE will apply it in a location-specific way

Value

A KML file is produced in the current working directory.

Author(s)

Nils Arrigo, [email protected] 2012 EEB, the University of Arizona, Tucson

See Also

par plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Preparing fake matrix
center = cbind(1:6, 1:6)
nesting = rep(1:3, each = 2)
fakeVar1 = rnorm(300, 0, 1)
fakeVar2 = rnorm(300, 0, 1)

fakematrix = data.frame(nesting, center, fakeVar1, fakeVar2)
fakematrix


## Preparing a user-defined function for producing the desired plots
myfun = function(input){
  plot(input[, 4], input[, 5], xlab='Xlab label', ylab='Ylab label', type = 'n', bty = 'n')
  points(input[, 4], input[, 5], col='red', pch = 16, cex = 2)
  }
 
 
## Producing KML - the easy way
Plots2GE(data = fakematrix,
	 center = fakematrix[, 2:3], 
	 nesting = fakematrix[, 1], 
	 customfun = myfun,
	 goo = "Plots2GE_V1.kml",
	 testrun = FALSE)

Example output

    nesting X1 X2     fakeVar1     fakeVar2
1         1  1  1  1.215235738 -0.621507947
2         1  2  2 -0.706120815 -0.142678926
3         2  3  3 -0.036302256 -0.215837845
4         2  4  4  0.469776302 -0.391623833
5         3  5  5 -0.273604760 -1.612479887
6         3  6  6 -0.370116322  0.193125489
7         1  1  1 -1.508463962 -1.572340159
8         1  2  2 -0.835758459 -1.732791829
9         2  3  3  0.045491416  0.294219977
10        2  4  4  0.461519840  0.661030276
11        3  5  5 -0.468912456  0.147073234
12        3  6  6 -0.709421905 -0.756265328
13        1  1  1 -2.123722923 -0.279213041
14        1  2  2 -1.939298108  1.966773134
15        2  3  3 -1.343896670 -0.382144501
16        2  4  4  0.378829318  0.422566342
17        3  5  5  1.519834416  0.969877195
18        3  6  6 -0.214348592 -0.330378564
19        1  1  1  0.624319626  0.872781611
20        1  2  2 -1.324955765 -0.282961042
21        2  3  3  1.031301809  0.692092037
22        2  4  4 -1.544212326 -1.294331240
23        3  5  5  0.518777855 -1.718786030
24        3  6  6  0.755282064 -0.925566076
25        1  1  1  0.540970120 -0.825493076
26        1  2  2  0.491775030  2.157006985
27        2  3  3 -0.036997148  0.288838241
28        2  4  4  0.575976437 -1.004792083
29        3  5  5 -0.609523100 -0.727254764
30        3  6  6 -1.167679971 -0.803107496
31        1  1  1 -1.934633787  1.860369922
32        1  2  2 -3.622018597  0.354563659
33        2  3  3 -0.070885133 -1.027036340
34        2  4  4 -1.157451799 -0.015159511
35        3  5  5 -1.878564860 -0.741024341
36        3  6  6  1.350236613  0.588565370
37        1  1  1 -0.273937017 -0.079756745
38        1  2  2 -0.101394966 -0.161334448
39        2  3  3  1.573341589 -0.179213315
40        2  4  4  0.472540861  0.384933391
41        3  5  5  0.897621923  1.128931871
42        3  6  6 -0.139379016  0.285724312
43        1  1  1  0.293801693  0.386864588
44        1  2  2 -0.424020327  0.295864230
45        2  3  3  0.082202667 -0.442463961
46        2  4  4  0.874996583  1.339240530
47        3  5  5 -0.198839368  0.596025584
48        3  6  6 -0.648247178 -0.842545055
49        1  1  1 -1.631643247  0.971830633
50        1  2  2  2.050320475  0.467431244
51        2  3  3 -1.888734142 -0.476278651
52        2  4  4  0.536684051 -1.856311034
53        3  5  5  0.795906802  1.239100757
54        3  6  6 -0.150967753 -1.906509450
55        1  1  1 -0.214521407  0.835334106
56        1  2  2  0.639853168  0.970146762
57        2  3  3 -1.833665744  0.174123281
58        2  4  4  1.896159704 -0.782131087
59        3  5  5  1.102890868 -1.463356621
60        3  6  6 -0.602299640  0.619360620
61        1  1  1 -0.694838820 -0.219858702
62        1  2  2  0.367556067  0.963645463
63        2  3  3  0.024420900  1.791281214
64        2  4  4  0.062435987 -0.096088050
65        3  5  5 -0.431133313  0.564829462
66        3  6  6 -0.647048347 -0.831186402
67        1  1  1 -1.304736279  1.041351499
68        1  2  2  1.328971323 -0.228669225
69        2  3  3 -0.473971653 -0.977671942
70        2  4  4 -1.168440145  0.398975318
71        3  5  5 -0.725428514  2.066954153
72        3  6  6  1.361370630 -0.020265892
73        1  1  1  1.524093609 -1.592200938
74        1  2  2 -0.215291384 -2.245091583
75        2  3  3 -1.425123626 -2.491797129
76        2  4  4  1.454946748 -0.607307528
77        3  5  5 -0.150369093  0.724597013
78        3  6  6  1.806436877  0.019824458
79        1  1  1 -1.018489101  1.002134862
80        1  2  2  0.101138146 -0.410919452
81        2  3  3 -0.008021906  2.294667722
82        2  4  4 -1.203099089 -0.783415298
83        3  5  5  0.549377533  1.342231529
84        3  6  6  1.123831127 -0.578000559
85        1  1  1  1.089327592 -0.195616229
86        1  2  2  0.535701889 -1.093651975
87        2  3  3 -0.660858603 -2.112454174
88        2  4  4  0.304529070  0.896680962
89        3  5  5  0.302040689 -0.436888003
90        3  6  6  1.193498894 -0.605053304
91        1  1  1 -0.475317791 -2.078814022
92        1  2  2  0.978406754 -0.183684379
93        2  3  3  1.348089186 -1.322483350
94        2  4  4 -0.274560903 -0.307329218
95        3  5  5 -0.897431656  0.005173196
96        3  6  6 -0.927373736  1.163166401
97        1  1  1 -0.598478996 -0.269346179
98        1  2  2 -0.137457837  0.780277270
99        2  3  3  1.486366728 -0.354139826
100       2  4  4 -0.131082223  0.069183769
101       3  5  5  1.330843644  0.261694484
102       3  6  6 -0.785337423 -0.662500574
103       1  1  1  0.282303070  1.100323026
104       1  2  2  0.477878996  0.674345452
105       2  3  3  0.569066138 -0.297841364
106       2  4  4 -0.089012500 -0.865080529
107       3  5  5 -0.360362827 -0.383667367
108       3  6  6  1.590024967  1.273756577
109       1  1  1  0.800775532  0.522780671
110       1  2  2  0.411503818 -0.225496803
111       2  3  3  0.244776681 -1.825324716
112       2  4  4  0.454323629  1.707621707
113       3  5  5 -1.176705001 -0.717991055
114       3  6  6  1.789972107  0.264755922
115       1  1  1 -0.919529566  0.824239970
116       1  2  2 -1.456426607 -0.714226575
117       2  3  3 -0.072842227 -0.811314309
118       2  4  4 -0.159375954 -0.245017135
119       3  5  5 -0.213498675 -1.203937446
120       3  6  6  0.032611572 -0.830848389
121       1  1  1  0.297532641 -0.071728225
122       1  2  2 -0.047522869  0.284419785
123       2  3  3 -1.008104977 -2.420571343
124       2  4  4 -0.586998002 -0.533532878
125       3  5  5  0.258582342  0.438930491
126       3  6  6 -0.458461332 -1.993805898
127       1  1  1  0.912437072  0.296987833
128       1  2  2  0.477528077 -0.403669730
129       2  3  3 -0.538122456  0.784609261
130       2  4  4 -0.808549934  0.028855818
131       3  5  5  0.502275885 -1.522199023
132       3  6  6 -0.408065110 -0.261699443
133       1  1  1 -1.065758500  1.173482959
134       1  2  2  0.455237573  0.807120684
135       2  3  3 -0.450613265 -1.927418457
136       2  4  4 -0.563407049 -0.196493707
137       3  5  5 -0.247872668 -0.556084337
138       3  6  6 -0.430478719 -0.493819011
139       1  1  1  1.414270589 -0.632309049
140       1  2  2  0.708257189  1.064017214
141       2  3  3 -0.741049499 -0.098920462
142       2  4  4  1.565612406 -1.006998191
143       3  5  5 -1.046904461  0.451097990
144       3  6  6 -1.293881942 -2.271942896
145       1  1  1  0.260332867 -0.085150713
146       1  2  2 -0.386698575  0.273405629
147       2  3  3 -1.565295107 -0.591408740
148       2  4  4  0.504037471  0.271188552
149       3  5  5 -1.366456342 -0.773745865
150       3  6  6  1.042898418 -0.109130751
151       1  1  1 -0.522630734  0.549033159
152       1  2  2 -0.203433121 -0.211140881
153       2  3  3 -1.164388352 -0.769087773
154       2  4  4 -0.849554391 -0.606303038
155       3  5  5 -0.786720535  0.802260433
156       3  6  6 -0.898399974 -0.504495674
157       1  1  1 -1.261658072  0.015273325
158       1  2  2  2.523124323  0.044637876
159       2  3  3 -0.740611614  0.089335413
160       2  4  4  0.491872622 -1.763320772
161       3  5  5  0.893053843  0.648318504
162       3  6  6  0.584547139 -0.256383881
163       1  1  1 -0.385318818 -0.498029091
164       1  2  2  0.339946443 -0.299356852
165       2  3  3 -0.824582023  0.454201044
166       2  4  4 -0.186607952  0.257206532
167       3  5  5  0.961579813 -1.083769360
168       3  6  6  2.062993552  1.902933372
169       1  1  1 -0.075058546 -0.187567481
170       1  2  2  0.761912497 -0.333569014
171       2  3  3  1.881164396 -0.644862013
172       2  4  4 -0.307339123  1.982581640
173       3  5  5 -2.274887136  1.263656994
174       3  6  6 -0.291366119  2.297113789
175       1  1  1 -1.270638773 -0.148669756
176       1  2  2 -1.124669713 -0.056913431
177       2  3  3  1.308559937 -1.013030698
178       2  4  4  2.178689170  0.358313103
179       3  5  5  0.055321615 -0.555922027
180       3  6  6  1.006947965 -2.870609052
181       1  1  1  1.091200835  0.132639450
182       1  2  2 -1.309953586 -0.142023541
183       2  3  3 -0.014866505  0.167084349
184       2  4  4 -1.725763567 -0.407826697
185       3  5  5 -1.047553170 -1.273181022
186       3  6  6  0.025956820 -1.325200034
187       1  1  1 -0.692522540  0.524817241
188       1  2  2  0.127157411  0.260536370
189       2  3  3  0.169605813 -1.769738388
190       2  4  4 -0.248492117  0.263890599
191       3  5  5  0.450677463 -0.397358699
192       3  6  6  1.018564573 -1.178031862
193       1  1  1  0.990415573  1.333348213
194       1  2  2 -1.232027745 -0.622906040
195       2  3  3 -1.145999812  0.501707869
196       2  4  4  0.559811656  0.030068801
197       3  5  5 -0.578971817  1.710643164
198       3  6  6 -0.108266965  0.252815181
199       1  1  1  0.952741075  0.556153417
200       1  2  2 -0.055249788  0.810956638
201       2  3  3 -0.207935027 -0.574547003
202       2  4  4 -1.374074747  1.301933585
203       3  5  5 -0.124041395 -1.717333020
204       3  6  6 -1.590445699  0.983131704
205       1  1  1  0.943970483 -0.427831338
206       1  2  2  0.752714140  0.329946896
207       2  3  3  0.996339272  0.375774305
208       2  4  4 -1.885351931  0.098927698
209       3  5  5  1.978515339  0.743711643
210       3  6  6  0.145341430 -0.288640219
211       1  1  1  0.047080846  0.018474536
212       1  2  2  0.731046603 -1.959116903
213       2  3  3 -0.204875858  0.242860725
214       2  4  4  0.847494416  0.215361832
215       3  5  5 -0.351075866  0.283114083
216       3  6  6  0.194615619 -0.215437193
217       1  1  1  1.435336070 -0.692882538
218       1  2  2  1.537675603 -0.680372558
219       2  3  3  1.201464307  0.795716996
220       2  4  4 -0.283495722 -0.856314004
221       3  5  5 -0.835938060  0.300484273
222       3  6  6 -2.367747643  1.089635866
223       1  1  1 -1.107709961 -1.306094635
224       1  2  2  1.021178458  0.145579415
225       2  3  3 -1.889768375 -0.393950767
226       2  4  4 -1.711970547  0.833764928
227       3  5  5 -0.164299719 -0.065925910
228       3  6  6 -1.970118117 -0.131436883
229       1  1  1  1.545903366 -1.312731836
230       1  2  2  0.103905450  0.811736239
231       2  3  3  0.167249304  0.249294950
232       2  4  4  0.487409403  1.220992652
233       3  5  5 -0.033872437 -1.579753308
234       3  6  6  1.192353445 -0.290835334
235       1  1  1 -0.851158019  1.008347132
236       1  2  2  1.663460756  0.849163027
237       2  3  3 -0.788010307  2.141012550
238       2  4  4 -1.178548372 -0.333963782
239       3  5  5 -1.258393369  0.317398928
240       3  6  6  1.694701878 -0.880773189
241       1  1  1  1.124803351  0.850785772
242       1  2  2  0.935524989  1.243025031
243       2  3  3 -0.038367181  2.036590527
244       2  4  4  1.290696769  1.956151960
245       3  5  5  1.344442988 -0.576087248
246       3  6  6  0.271507909  0.719649703
247       1  1  1 -0.306665952  1.561881090
248       1  2  2 -0.544704732  0.113807605
249       2  3  3 -0.073564208 -0.317853975
250       2  4  4 -1.051926845  0.973693697
251       3  5  5  0.063067873 -0.829409006
252       3  6  6  0.214870506  1.386441430
253       1  1  1  2.210965568  0.187144229
254       1  2  2 -0.871928087  2.445935978
255       2  3  3  0.556637549  0.072099976
256       2  4  4  1.229074050 -0.524143923
257       3  5  5  0.184899588 -0.425703733
258       3  6  6  0.134915162  0.084168993
259       1  1  1 -0.456078541  0.643119318
260       1  2  2  0.315756389  0.196516325
261       2  3  3  0.386072156 -0.501553174
262       2  4  4 -0.245156796  1.030776861
263       3  5  5  1.048265403 -0.679231651
264       3  6  6 -0.704740095 -0.031811873
265       1  1  1  1.222350900  0.953319532
266       1  2  2 -0.881838286  0.514735757
267       2  3  3  0.112989228 -0.707527725
268       2  4  4 -0.053408589 -0.875674636
269       3  5  5  0.395281701 -0.276224681
270       3  6  6 -1.752145449 -1.363360964
271       1  1  1 -1.114575792  0.233617435
272       1  2  2 -1.968908876  1.962819397
273       2  3  3 -0.048471304  0.945732006
274       2  4  4  2.262328054  0.069954510
275       3  5  5 -0.545468649  0.184861762
276       3  6  6  0.636065130 -0.040440841
277       1  1  1 -1.664419332  1.945205295
278       1  2  2  0.977024841 -0.290338764
279       2  3  3  0.244288073 -0.953302725
280       2  4  4 -1.923058777  2.751231240
281       3  5  5  0.750438667 -0.765474917
282       3  6  6  1.325337672  0.249585685
283       1  1  1  0.195416897  0.186264148
284       1  2  2 -2.237113420 -0.040381763
285       2  3  3  0.269327678  0.228608175
286       2  4  4  0.700739178 -0.240992770
287       3  5  5  0.703403024 -1.755731791
288       3  6  6 -0.247560218  1.189180955
289       1  1  1  1.669663235  0.332044047
290       1  2  2 -0.859317894 -1.252455159
291       2  3  3 -0.550080048  1.951560645
292       2  4  4  0.757324332  1.046925273
293       3  5  5  1.493291585  0.830790400
294       3  6  6  1.378049719 -0.133804607
295       1  1  1  0.271472086 -1.218276773
296       1  2  2  1.302116287 -0.046463450
297       2  3  3  0.226763239 -0.376842617
298       2  4  4 -0.861745954 -0.626033775
299       3  5  5 -2.154573076 -0.431971878
300       3  6  6  0.906954031  0.683748730

R2G2 documentation built on May 29, 2017, 1:41 p.m.