Memuat paket tambahan yang digunakan.
library("rgdal")
library("sf")
library("ggplot2")
library("ggspatial")
sbp <- read.csv("spasial bubble plot.csv")
head(sbp)
## lat long lokasi kelimpahan
## 1 -3.6780 128.1438 St.1 87
## 2 -3.6966 128.1687 St.2 17
## 3 -3.6840 128.1818 St.3 89
## 4 -3.6733 128.1745 St.4 84
## 5 -3.6643 128.1781 St.5 55
## 6 -3.6623 128.1954 St.6 24
Data area kajian yang berupa poligon (.shp) diekstrak agar dapat digunakan sebagai dasar peta.
area <- readOGR(dsn = "Area Kajian/ADMINISTRASIKECAMATAN_AR_50K.shp")
# ubah data ke bentuk data frame
area_f <- fortify(area)
class(area_f)
# memotong (slicing) peta
lonrange.sf <- c(128.1, 128.3)
latrange.sf <- c(-3.6, -3.8)
# visualisasi
ggplot() +
geom_polygon(data = area_f, aes(x=long, y = lat, group = group), fill="grey",
alpha=1) + #peta dasar
geom_point(data = sbp, aes(x=long, y=lat, size=kelimpahan), stat = "identity",
alpha=0.9, color = "#0C7BDC") + #buble plot
geom_text(data = sbp, aes(x=long, y= lat, label = lokasi), size = 3.5,
colour = "black") + #keterangan stasiun
scale_size_continuous(range=c(2, 10), breaks = c(0, 20, 40, 60, 80)) + #ukuran bubble plot
coord_sf(ylim = latrange.sf, xlim = lonrange.sf, expand = FALSE) + #potong peta
annotation_north_arrow(location = "br", which_north = "grid",
pad_x = unit(0, "in"), pad_y = unit(0, "in"),
style = north_arrow_fancy_orienteering) + #arah mata angin
theme(
axis.text.y = element_text(colour = "black", size = 10, face = "bold", family="serif"),
axis.text.x = element_text(colour = "black", face = "bold", size = 10, family="serif"),
legend.text = element_text(size = 10, face ="bold", colour ="black", family="serif"),
legend.position = "right",
axis.title.y = element_text(face = "bold", size = 12, family="serif"),
axis.title.x = element_text(face = "bold", size = 12, colour = "black", family="serif"),
legend.title = element_text(size = 12, colour = "black", face = "bold", family="serif"),
panel.background = element_blank(),
panel.border = element_rect(colour = "black", fill = NA, linewidth = 1.2),
legend.key=element_blank()
) + #modifikasi ukuran, warna, dan jenis huruf pada sumbu x, sumbu y, dan legenda axes as well as legend
labs(size = expression(paste("Kelimpahan ", "(individu.", m^-1, ")")), x = "", y = "") #keterangan pada sumbu x, sumbu y, dan legenda
## R version 4.3.2 (2023-10-31 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19045)
##
## Matrix products: default
##
##
## locale:
## [1] LC_COLLATE=English_United States.utf8
## [2] LC_CTYPE=English_United States.utf8
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.utf8
##
## time zone: Asia/Jakarta
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] ggspatial_1.1.9 ggplot2_3.5.0 sf_1.0-15 rgdal_1.6-7
## [5] sp_2.1-3
##
## loaded via a namespace (and not attached):
## [1] gtable_0.3.4 jsonlite_1.8.8 highr_0.10 dplyr_1.1.4
## [5] compiler_4.3.2 tidyselect_1.2.0 Rcpp_1.0.12 jquerylib_0.1.4
## [9] scales_1.3.0 yaml_2.3.8 fastmap_1.1.1 lattice_0.21-9
## [13] R6_2.5.1 generics_0.1.3 classInt_0.4-10 knitr_1.45
## [17] tibble_3.2.1 units_0.8-5 munsell_0.5.0 DBI_1.2.2
## [21] bslib_0.6.1 pillar_1.9.0 rlang_1.1.3 utf8_1.2.4
## [25] cachem_1.0.8 xfun_0.42 sass_0.4.8 cli_3.6.2
## [29] withr_3.0.0 magrittr_2.0.3 class_7.3-22 digest_0.6.34
## [33] grid_4.3.2 rstudioapi_0.15.0 lifecycle_1.0.4 vctrs_0.6.5
## [37] KernSmooth_2.23-22 proxy_0.4-27 evaluate_0.23 glue_1.7.0
## [41] farver_2.1.1 colorspace_2.1-0 fansi_1.0.6 e1071_1.7-14
## [45] rmarkdown_2.25 tools_4.3.2 pkgconfig_2.0.3 htmltools_0.5.7