-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathREADME.Rmd
executable file
·861 lines (644 loc) · 27.5 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
---
title: "rangemap: Simple Tools for Defining Species Ranges"
author: "Marlon E. Cobos, Vijay Barve, Narayani Barve, Alberto Jimenez-Valverde, and Claudia Nunez-Penichet"
output:
github_document:
toc: yes
toc_depth: 3
always_allow_html: true
---
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(echo = TRUE, collapse = TRUE, comment = "#>", warning = FALSE)
```
<br>
<!-- badges: start -->
[![R build status](https://github.com/marlonecobos/rangemap/workflows/R-CMD-check/badge.svg)](https://github.com/marlonecobos/rangemap/actions)
<!-- badges: end -->
<img src='man/figures/rangemap100dpi.png' align="right" height="139" /></a>
<hr>
**This repository is for the GSoC 2018 project "Species range maps in R" (details at the end).**
## Package description
The **rangemap** R package presents various tools to create species range maps based on occurrence data, statistics, and SpatialPolygons objects. Other tools of this package can be used to analyze environmental characteristics of the species ranges and to create high quality figures of these maps. All the functions that create species ranges can also generate representations of species extents of occurrence (using convex hulls) and areas of occupancy according to the IUCN criteria. Shapefiles of the resulting polygons can be saved in the working directory if it is needed.
<br>
### News
Starting with v 0.1.17, **rangemap** allows optional calculations of extents of occurrence and areas of occupancy in all main functions (see below). To avoid performing analysies related with these areas, set arguments `extent_of_occurrence` and `area_of_occupancy` to `FALSE`. This change can save time, specially if a large number of occurrences is used.
<br>
<hr>
## Installing the package
A stable version of **rangemap** can be installed from CRAN as follows:
```{r, include=TRUE, eval=FALSE}
install.packages("rangemap")
```
**rangemap** can also be installed from its GitHub repository using the following code:
```{r, include=TRUE, eval=FALSE}
if(!require(remotes)){
install.packages("remotes")
}
remotes::install_github("marlonecobos/rangemap")
```
<br>
<hr>
## Using the package functions
### Preparing R
The following code chunk loads the pacakges needed to perform some example-analyses with **rangemap**.
```{r, include=TRUE, eval=FALSE}
# packages to be used
library(raster)
library(maps)
library(maptools)
library(rangemap)
```
The working directory will also be defined in this part.
```{r, eval=FALSE, include=TRUE}
# working directory
setwd("YOUR/WORKING/DIRECTORY")
```
<br>
<hr>
### Simple graphical exploration of your data.
The *rangemap_explore* function generates simple figures to visualize species occurrence data in the geographic space before using other functions of this package. The figure created with this function helps to identify countries involved in the species distribution. Other aspects of the species distribution can also be generally checked here; for instance, disjunct distributions, general dimension of the species range, etc.
The function's help can be consulted using the following line of code:
```{r, eval=FALSE, include=TRUE}
help(rangemap_explore)
```
An example of the use of this function is written below.
```{r, include=TRUE, eval=FALSE}
# getting the data
data("occ_d", package = "rangemap")
# simple figure of the species occurrence data
rangemap_explore(occurrences = occ_d)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-6-1.png")
```
Same figure with country codes.
```{r, include=TRUE, eval=FALSE}
# simple figure of the species occurrence data
rangemap_explore(occurrences = occ_d, show_countries = TRUE)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-7-1.png")
```
<br>
<hr>
### Species ranges from buffered occurrences
The *rangemap_buff* function generates a distributional range for a given species by buffering provided occurrences using a user-defined distance.
The function's help can be consulted using the following line of code:
```{r, eval=FALSE, include=TRUE}
help(rangemap_buffer)
```
An example of how to use this function is written below.
```{r, include=TRUE, eval=FALSE}
# getting the data
data("occ_p", package = "rangemap")
# species range
buff_range <- rangemap_buffer(occurrences = occ_p, buffer_distance = 100000)
summary(buff_range)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: Buffer
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Peltophryne empusa 27 106241.2 66357.71
#> Area_of_occupancy
#> 92
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 1 SpatialPolygonsDataFrame S4
#> species_unique_records 27 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 23 SpatialPolygonsDataFrame S4
```
The function *rangemap_plot* generates customizable figures of species range maps using the objects produced by other function of this package. Let's see how the generated range looks like.
```{r, include=TRUE, eval=FALSE}
rangemap_plot(buff_range)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-10-1.png")
```
For further details see the function documentation.
```{r, eval=FALSE, include=TRUE}
help(rangemap_plot)
```
<br>
<hr>
### Species ranges from boundaries
The *rangemap_boundaries* function generates a distributional range for a given species by considering all the polygons of administrative entities in which the species has been detected.
The function's help can be consulted using the following line of code:
```{r, eval=FALSE, include=TRUE}
help(rangemap_boundaries)
```
Examples of the use of this function with most of its variants are written below.
<br>
#### Using only occurrences
Following there is an example in which administrative areas will be selected using only occurrences. The *rangemap_explore* function will be used for obtaining a first visualization of the species distributional range.
```{r, include=TRUE, eval=FALSE}
# occurrence data was obtained in the first example using
# data("occ_d", package = "rangemap")
# checking which countries may be involved in the analysis
rangemap_explore(occurrences = occ_d, show_countries = TRUE)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-13-1.png")
```
```{r, include=TRUE, eval=FALSE}
# getting an example of SpatialPolygonsDataFrame to be used as polygons
data("adm_boundaries", package = "rangemap")
# species range
bound_range <- rangemap_boundaries(occurrences = occ_d, polygons = adm_boundaries)
summary(bound_range)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: Boundaries
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Dasypus kappleri 55 12217732 4076154
#> Area_of_occupancy
#> 176
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 7 SpatialPolygonsDataFrame S4
#> species_unique_records 55 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 44 SpatialPolygonsDataFrame S4
```
Figure of the generated range.
```{r, include=TRUE, eval=FALSE}
rangemap_plot(bound_range)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-14-1.png")
```
<br>
#### Using only administrative area names
Following there is an example in which administrative areas will be selected using only the names of the administrative entities known to be occupied by the species. This approach may be useful in circumstances where geographic coordinates or accurate locality descriptions do not exist.
```{r, include=TRUE, eval=FALSE}
# administrative areas invloved
adm <- c("Ecuador", "Peru", "Venezuela", "Colombia", "Brazil")
# species range
bound_range1 <- rangemap_boundaries(adm_areas = adm, polygons = adm_boundaries)
summary(bound_range1)
#>
#> Summary of sp_range object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: Boundaries
#>
#> Species Range_area
#> Species 12043257
#>
#>
#>
#> Species range
#> Object of class SpatialPolygonsDataFrame
#> Coordinates:
#> min max
#> x -91.66389 -29.84000
#> y -33.74067 13.37861
#> Is projected: FALSE
#> proj4string : [+proj=longlat +datum=WGS84 +no_defs]
#> Data attributes:
#> X.Species. rangekm2
#> Length:5 Min. : 255493
#> Class :character 1st Qu.: 909405
#> Mode :character Median :1135524
#> Mean :2408651
#> 3rd Qu.:1294369
#> Max. :8448466
```
Map of the generated range.
```{r, include=TRUE, eval=FALSE}
rangemap_plot(bound_range1)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-16-1.png")
```
<br>
#### Using occurrences and administrative areas
An example of using both occurrences and administrative areas for creating species ranges with the function *rangemap_boundaries* is presented below. This option may be useful when these two types of information complement the knowledge of the species distribution.
```{r, include=TRUE, eval=FALSE}
# other parameters
adm <- "Ecuador" # Athough no record is on this country, we know it is in Ecuador
# species range
bound_range2 <- rangemap_boundaries(occurrences = occ_d, adm_areas = adm,
polygons = adm_boundaries)
summary(bound_range2)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: Boundaries
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Dasypus kappleri 55 12473215 4076154
#> Area_of_occupancy
#> 176
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 8 SpatialPolygonsDataFrame S4
#> species_unique_records 55 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 44 SpatialPolygonsDataFrame S4
```
Now the plot.
```{r, include=TRUE, eval=FALSE}
rangemap_plot(bound_range2)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-18-1.png")
```
<br>
<hr>
### Species ranges from hull polygons
The *rangemap_hull* function generates a species range polygon by creating convex or concave hull polygons based on occurrence data.
The function's help can be consulted using the following line of code:
```{r, eval=FALSE, include=TRUE}
help(rangemap_hull)
```
Examples of the use of this function with most of its variants are written below.
<br>
#### Convex hulls
With the example provided below, a species range will be constructed using convex hulls. After that this range will be split based on two distinct algorithms of clustering: hierarchical and k-means. Convex hull polygons are commonly used to represent species ranges, however in circumstances where biogeographic barriers for the species dispersal exist, concave hulls may be a better option.
```{r, include=TRUE, eval=FALSE}
# occurrences were obtained in prvious examples using
# data("occ_d", package = "rangemap")
# species range
hull_range <- rangemap_hull(occurrences = occ_d, hull_type = "convex",
buffer_distance = 100000)
#> Hull type: convex
summary(hull_range)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: Convex_hull
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Dasypus kappleri 56 4860934 4095146
#> Area_of_occupancy
#> 184
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 6 SpatialPolygonsDataFrame S4
#> species_unique_records 56 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 46 SpatialPolygonsDataFrame S4
# disjunct distributions
# clustering occurrences with the hierarchical method
# species range
hull_range1 <- rangemap_hull(occurrences = occ_d, hull_type = "convex",
buffer_distance = 100000, split = TRUE,
cluster_method = "hierarchical",
split_distance = 1500000)
#> Clustering method: hierarchical
#> Hull type: convex
summary(hull_range1)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: Convex_hull_split
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Dasypus kappleri 56 2115826 4095146
#> Area_of_occupancy
#> 184
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 7 SpatialPolygonsDataFrame S4
#> species_unique_records 56 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 46 SpatialPolygonsDataFrame S4
# clustering occurrences with the k-means method
# species range
hull_range2 <- rangemap_hull(occurrences = occ_d, hull_type = "convex",
buffer_distance = 100000, split = TRUE,
cluster_method = "k-means", n_k_means = 3)
#> Clustering method: k-means
#> Hull type: convex
summary(hull_range2)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: Convex_hull_split
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Dasypus kappleri 56 2115826 4095146
#> Area_of_occupancy
#> 184
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 7 SpatialPolygonsDataFrame S4
#> species_unique_records 56 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 46 SpatialPolygonsDataFrame S4
```
Now the figure of the species range.
```{r, include=TRUE, eval=FALSE}
rangemap_plot(hull_range) # try hull_range1 and hull_range2 as well
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-21-1.png")
```
<br>
#### Concave hulls
With the following examples, the species range will be constructed using concave hulls. The species range will be calculated as an only area and as disjunct areas by clustering its occurrences using the k-means and hierarchical methods.
```{r, include=TRUE, eval=FALSE}
# occurrences were obtained in prvious examples using
# data("occ_d", package = "rangemap")
# species range
hull_range3 <- rangemap_hull(occurrences = occ_d, hull_type = "concave",
buffer_distance = 100000)
#> Hull type: concave
summary(hull_range3)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: Concave_hull
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Dasypus kappleri 56 4327930 4095146
#> Area_of_occupancy
#> 184
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 4 SpatialPolygonsDataFrame S4
#> species_unique_records 56 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 46 SpatialPolygonsDataFrame S4
# disjunct distributions
# clustering occurrences with the hierarchical method
# species range
hull_range4 <- rangemap_hull(occurrences = occ_d, hull_type = "concave",
buffer_distance = 100000, split = TRUE,
cluster_method = "hierarchical",
split_distance = 1500000)
#> Clustering method: hierarchical
#> Hull type: concave
summary(hull_range4)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: Concave_hull_split
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Dasypus kappleri 56 1878355 4095146
#> Area_of_occupancy
#> 184
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 6 SpatialPolygonsDataFrame S4
#> species_unique_records 56 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 46 SpatialPolygonsDataFrame S4
# clustering occurrences with the k-means method
# species range
hull_range5 <- rangemap_hull(occurrences = occ_d, hull_type = "concave",
buffer_distance = 100000, split = TRUE,
cluster_method = "k-means", n_k_means = 3)
#> Clustering method: k-means
#> Hull type: concave
summary(hull_range5)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: Concave_hull_split
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Dasypus kappleri 56 1878355 4095146
#> Area_of_occupancy
#> 184
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 6 SpatialPolygonsDataFrame S4
#> species_unique_records 56 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 46 SpatialPolygonsDataFrame S4
```
Checking the figure.
```{r, include=TRUE, eval=FALSE}
rangemap_plot(hull_range5) # try hull_range4 and hull_range3 as well
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-23-1.png")
```
<br>
<hr>
### Species ranges from ecological niche model outputs
The *rangemap_enm* function generates a distributional range for a given species using a continuous raster layer produced with an ecological niche modeling algorithm. This function binarizes the model into suitable and unsuitable areas using a user specified level of omission (a given threshold value).
The function's help can be consulted using the following line of code:
```{r, eval=FALSE, include=TRUE}
help(rangemap_enm)
```
An example of the use of this function is written below.
```{r, include=TRUE, eval=FALSE}
# parameters
sp_mod <- raster::raster(list.files(system.file("extdata", package = "rangemap"),
pattern = "sp_model.tif", full.names = TRUE))
data("occ_train", package = "rangemap")
# species range
enm_range <- rangemap_enm(occurrences = occ_train, model = sp_mod,
threshold_omission = 5)
summary(enm_range)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: ENM
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Amblyomma_americanum 89 2824883 3535078
#> Area_of_occupancy
#> 356
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 11 SpatialPolygonsDataFrame S4
#> species_unique_records 89 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 89 SpatialPolygonsDataFrame S4
```
Let's see how this range looks like.
```{r, include=TRUE, eval=FALSE}
rangemap_plot(enm_range)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-26-1.png")
```
<br>
<hr>
### Species ranges using trend surface analyses
The *rangemap_tsa* function generates species range polygons for a given species using a trend surface analysis. Trend surface analysis is a method based on low-order polynomials of spatial coordinates for estimating a regular grid of points from scattered observations. This method assumes that all cells not occupied by occurrences are absences; hence its use depends on the quality of data and the certainty of having or not a complete sampling of the region of interest.
The function's help can be consulted using the following line of code:
```{r, eval=FALSE, include=TRUE}
help(rangemap_tsa)
```
An example of the use of this function is written below.
```{r, include=TRUE, eval=FALSE}
# data
data("occ_f", package = "rangemap")
CU <- simple_wmap("simple", regions = "Cuba")
# species range
tsa_r <- rangemap_tsa(occurrences = occ_f, region_of_interest = CU)
summary(tsa_r)
#>
#> Summary of sp_range_iucn object
#> ---------------------------------------------------------------------------
#>
#> Species range derived from: TSA
#>
#> Species Unique_records Range_area Extent_of_occurrence
#> Peltophryne fustiger 18 6825 1630.968
#> Area_of_occupancy
#> 48
#>
#>
#>
#> Other contents:
#> Length Class Mode
#> species_range 1 SpatialPolygonsDataFrame S4
#> species_unique_records 18 SpatialPointsDataFrame S4
#> extent_of_occurrence 1 SpatialPolygonsDataFrame S4
#> area_of_occupancy 12 SpatialPolygonsDataFrame S4
```
Let's take a look at the results.
```{r, include=TRUE, eval=FALSE}
rangemap_plot(tsa_r, polygons = CU, zoom = 0.5)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-29-1.png")
```
<br>
<hr>
### Nice figures of species ranges
The *rangemap_plot* function can be used to plot not only the generated species ranges but also the extent of occurrence and the species records in the same map. The species range will be plot on a simplified world map, but other SpatialPolygons objects can be used.
The function's help can be consulted using the following line of code:
```{r, eval=FALSE, include=TRUE}
help(rangemap_plot)
```
Examples of the use of this function are written below.
#### Including extent of occurrence
```{r, include=TRUE, eval=FALSE}
rangemap_plot(hull_range5, add_EOO = TRUE)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-31-1.png")
```
<br>
#### Including occurrences
```{r, include=TRUE, eval=FALSE}
rangemap_plot(hull_range5, add_occurrences = TRUE)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-32-1.png")
```
<br>
#### Including extent of occurrence and species records
```{r, include=TRUE, eval=FALSE}
rangemap_plot(hull_range5, add_EOO = TRUE, add_occurrences = TRUE)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-33-1.png")
```
<br>
#### Using other parameters
```{r, include=TRUE, eval=FALSE}
rangemap_plot(hull_range5, add_EOO = TRUE, add_occurrences = TRUE,
legend = TRUE, scalebar = TRUE, scalebar_length = 500,
zoom = 0.5, northarrow = TRUE)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-34-1.png")
```
<br>
<hr>
### Species ranges and environmental factors
#### Species ranges on layers of environmental variables
The *ranges_emaps* function represents one or more ranges of the same species on various maps of environmental factors (e.g. climatic variables) to detect implications of using distinct types of ranges when looking at environmental conditions in the area. Figures can be saved using some of the function's arguments.
The function's help can be consulted using the following line of code:
```{r, eval=FALSE, include=TRUE}
help(ranges_emaps)
```
An example of the use of this function is written below.
```{r, include=TRUE, eval=FALSE}
# example data
data("buffer_range", package = "rangemap")
data("cxhull_range", package = "rangemap")
data("cvehull_range", package = "rangemap")
vars <- raster::stack(system.file("extdata", "variables.tif",
package = "rangemap"))
names(vars) <- c("bio5", "bio6", "bio13", "bio14")
# plotting
ranges_emaps(buffer_range, cxhull_range, cvehull_range, variables = vars)
```
```{r, echo=FALSE}
knitr::include_graphics("man/figures/unnamed-chunk-36-1.png")
```
<br>
#### Species ranges in environmental space
The *ranges_espace* function generates a three dimensional comparison of a species' ranges created using distinct algorithms, to visualize implications of selecting one of them if environmental conditions are considered.
The function's help can be consulted using the following line of code:
```{r, eval=FALSE, include=TRUE}
help(ranges_espace)
```
An example of the use of this function is written below.
```{r, eval=FALSE, include=TRUE}
# example data
data("buffer_range", package = "rangemap")
data("cxhull_range", package = "rangemap")
vars <- raster::stack(system.file("extdata", "variables.tif",
package = "rangemap"))
names(vars) <- c("bio5", "bio6", "bio13", "bio14")
## comparison
ranges_espace(buffer_range, cxhull_range, variables = vars,
add_occurrences = TRUE)
# you can zoom in and rotate the figure for understanding it better
```
Saving this figures for publication can be done using functions from the package `rgl` (e.g., `rgl.postscript()` and `rgl.snapshot()`) .
<br>
<hr>
## Project description
Student: *Marlon E. Cobos*
Mentors: *Narayani Barve, Vijay Barve, and Alberto Jimenez Valverde*
The species range maps project is motivated by the importance of information about species distribution for processes of conservation planning and the study of spatial patterns of biodiversity. In the face of multiple threats related to Global Change, protection and mitigation actions are crucial for maintaining the health of the planet, and knowing where species are located constitutes in primary information for starting these efforts. Currently, generation of species ranges maps may take several steps and the use of specialized software. Thanks to the recent development of specialized packages, R is rapidly becoming an excellent alternative for analyzing the spatial patterns of biodiversity. Taking advantage of these packages and the versatility of R, the aim of this project was offering handily and robust open source tools to obtain reliable proposals of species distribution ranges and to analyze their geographical patterns. A large community of students, researchers, and conservation managers can be benefited by this project since these tools will be freely available and will improve the way in which studies of species distributions are developed.
### Status of the project
A version of the package **rangemap** (the result of the project) is in CRAN and can be found <a href=" https://CRAN.R-project.org/package=rangemap" target="_blank">here</a>.
All commits made can be seen at the <a href="https://github.com/marlonecobos/rangemap/commits/master" target="_blank">complete list of commits</a>.