library(leaflet) # mapping
library(sf) # for spatial data analysis
## Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 7.2.1; sf_use_s2() is TRUE
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.2 --
## v ggplot2 3.3.6 v purrr 0.3.4
## v tibble 3.1.8 v dplyr 1.0.10
## v tidyr 1.2.1 v stringr 1.4.1
## v readr 2.1.3 v forcats 0.5.2
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(ggplot2)
library(tmap)
library(dplyr)
library(readxl)
Village_GPS4 <- read_csv("D:/R_Studio/Village_GPS4.csv")
## Rows: 72 Columns: 8
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): Village_name
## dbl (7): longitude, latitude, funestus_prop, gambiae_prop, arabiensis_prop, ...
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
The st_layers() function list all layer names and their type in a data source
minboundaries_tabulardata <- st_read("D:/R_Studio/ken_adm_iebc_20191031_shp/ken_admbnda_adm1_iebc_20191031.shp")
## Reading layer `ken_admbnda_adm1_iebc_20191031' from data source
## `D:\R_Studio\ken_adm_iebc_20191031_shp\ken_admbnda_adm1_iebc_20191031.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 47 features and 12 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 33.91029 ymin: -4.67688 xmax: 41.90602 ymax: 5.414124
## Geodetic CRS: WGS 84
#st_read("D:/R_Studio/ken_adminboundaries_tabulardata.xlsx")
Adding circle markers to the Kenya map.
map <- leaflet() %>%
addTiles() %>%
setView(lng = 37, lat = 0.3, zoom = 6) %>%
addPolygons(data = minboundaries_tabulardata, color = "green", weight = 2, opacity = 1 ) %>%
addCircleMarkers( data = Village_GPS4,
lng = Village_GPS4$longitude,
lat = Village_GPS4$latitude,
radius = 5,
weight = 3,
color = "black")
map
sessionInfo()
## R version 4.1.2 (2021-11-01)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 22000)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_Kenya.1252 LC_CTYPE=English_Kenya.1252
## [3] LC_MONETARY=English_Kenya.1252 LC_NUMERIC=C
## [5] LC_TIME=English_Kenya.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] readxl_1.4.1 tmap_3.3-3 forcats_0.5.2 stringr_1.4.1
## [5] dplyr_1.0.10 purrr_0.3.4 readr_2.1.3 tidyr_1.2.1
## [9] tibble_3.1.8 ggplot2_3.3.6 tidyverse_1.3.2 sf_1.0-8
## [13] leaflet_2.1.1
##
## loaded via a namespace (and not attached):
## [1] fs_1.5.2 bit64_4.0.5 lubridate_1.8.0
## [4] RColorBrewer_1.1-3 httr_1.4.4 tools_4.1.2
## [7] backports_1.4.1 bslib_0.4.0 utf8_1.2.2
## [10] R6_2.5.1 KernSmooth_2.23-20 DBI_1.1.3
## [13] colorspace_2.0-3 raster_3.6-3 sp_1.5-0
## [16] withr_2.5.0 tidyselect_1.1.2 bit_4.0.4
## [19] compiler_4.1.2 leafem_0.2.0 cli_3.4.1
## [22] rvest_1.0.3 xml2_1.3.3 sass_0.4.2
## [25] scales_1.2.1 classInt_0.4-8 proxy_0.4-27
## [28] digest_0.6.29 rmarkdown_2.16 base64enc_0.1-3
## [31] dichromat_2.0-0.1 pkgconfig_2.0.3 htmltools_0.5.3
## [34] dbplyr_2.2.1 fastmap_1.1.0 htmlwidgets_1.5.4
## [37] rlang_1.0.6 rstudioapi_0.14 jquerylib_0.1.4
## [40] generics_0.1.3 jsonlite_1.8.2 vroom_1.6.0
## [43] crosstalk_1.2.0 googlesheets4_1.0.1 magrittr_2.0.3
## [46] Rcpp_1.0.9 munsell_0.5.0 fansi_1.0.3
## [49] abind_1.4-5 terra_1.6-17 lifecycle_1.0.2
## [52] stringi_1.7.8 leafsync_0.1.0 yaml_2.3.5
## [55] tmaptools_3.1-1 grid_4.1.2 parallel_4.1.2
## [58] crayon_1.5.2 lattice_0.20-45 haven_2.5.1
## [61] stars_0.5-6 hms_1.1.2 knitr_1.40
## [64] pillar_1.8.1 codetools_0.2-18 reprex_2.0.2
## [67] XML_3.99-0.10 glue_1.6.2 evaluate_0.16
## [70] leaflet.providers_1.9.0 modelr_0.1.9 png_0.1-7
## [73] vctrs_0.4.2 tzdb_0.3.0 cellranger_1.1.0
## [76] gtable_0.3.1 assertthat_0.2.1 cachem_1.0.6
## [79] xfun_0.33 lwgeom_0.2-9 broom_1.0.1
## [82] e1071_1.7-11 class_7.3-20 googledrive_2.0.0
## [85] viridisLite_0.4.1 gargle_1.2.1 units_0.8-0
## [88] ellipsis_0.3.2