library(sf)
## Linking to GEOS 3.13.1, GDAL 3.11.0, PROJ 9.6.0; sf_use_s2() is TRUE
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
#baca file data
peta <- st_read("C:/Users/ACER/Downloads/33.05_Kebumen/33.05_kecamatan.geojson")
## Reading layer `33.05_kecamatan' from data source 
##   `C:\Users\ACER\Downloads\33.05_Kebumen\33.05_kecamatan.geojson' 
##   using driver `GeoJSON'
## Simple feature collection with 26 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XYZ
## Bounding box:  xmin: 109.3788 ymin: -7.83123 xmax: 109.8393 ymax: -7.445676
## z_range:       zmin: 0 zmax: 0
## Geodetic CRS:  WGS 84
peta
## Simple feature collection with 26 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XYZ
## Bounding box:  xmin: 109.3788 ymin: -7.83123 xmax: 109.8393 ymax: -7.445676
## z_range:       zmin: 0 zmax: 0
## Geodetic CRS:  WGS 84
## First 10 features:
##    kd_propinsi kd_dati2 kd_kecamatan   nm_kecamatan
## 1           33       05          001           Ayah
## 2           33       05          002         Buayan
## 3           33       05          003         Puring
## 4           33       05          004      Petanahan
## 5           33       05          005        Klirong
## 6           33       05          006 Buluspesantren
## 7           33       05          007          Ambal
## 8           33       05          008          Mirit
## 9           33       05          009        Prembun
## 10          33       05          010   Kutowinangun
##                          geometry
## 1  MULTIPOLYGON Z (((109.411 -...
## 2  MULTIPOLYGON Z (((109.4689 ...
## 3  MULTIPOLYGON Z (((109.5242 ...
## 4  MULTIPOLYGON Z (((109.5908 ...
## 5  MULTIPOLYGON Z (((109.6439 ...
## 6  MULTIPOLYGON Z (((109.6697 ...
## 7  MULTIPOLYGON Z (((109.7117 ...
## 8  MULTIPOLYGON Z (((109.7954 ...
## 9  MULTIPOLYGON Z (((109.803 -...
## 10 MULTIPOLYGON Z (((109.724 -...
set.seed(100)

data <- data.frame(
  Kecamatan = peta$nm_kecamatan,   
  PM25 = sample(20:90, length(peta$nm_kecamatan), replace = TRUE)
)

head(data)
##        Kecamatan PM25
## 1           Ayah   42
## 2         Buayan   89
## 3         Puring   23
## 4      Petanahan   74
## 5        Klirong   89
## 6 Buluspesantren   26
# Gabungkan data dengan peta
peta_data <- left_join(peta, data, by=c("nm_kecamatan"="Kecamatan"))
peta_data
## Simple feature collection with 26 features and 5 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XYZ
## Bounding box:  xmin: 109.3788 ymin: -7.83123 xmax: 109.8393 ymax: -7.445676
## z_range:       zmin: 0 zmax: 0
## Geodetic CRS:  WGS 84
## First 10 features:
##    kd_propinsi kd_dati2 kd_kecamatan   nm_kecamatan PM25
## 1           33       05          001           Ayah   42
## 2           33       05          002         Buayan   89
## 3           33       05          003         Puring   23
## 4           33       05          004      Petanahan   74
## 5           33       05          005        Klirong   89
## 6           33       05          006 Buluspesantren   26
## 7           33       05          007          Ambal   26
## 8           33       05          008          Mirit   74
## 9           33       05          009        Prembun   62
## 10          33       05          010   Kutowinangun   80
##                          geometry
## 1  MULTIPOLYGON Z (((109.411 -...
## 2  MULTIPOLYGON Z (((109.4689 ...
## 3  MULTIPOLYGON Z (((109.5242 ...
## 4  MULTIPOLYGON Z (((109.5908 ...
## 5  MULTIPOLYGON Z (((109.6439 ...
## 6  MULTIPOLYGON Z (((109.6697 ...
## 7  MULTIPOLYGON Z (((109.7117 ...
## 8  MULTIPOLYGON Z (((109.7954 ...
## 9  MULTIPOLYGON Z (((109.803 -...
## 10 MULTIPOLYGON Z (((109.724 -...

Choropleth map

adalah peta tematik yang menampilkan data kuantitatif menggunakan gradasi warna sesuai dengan batas wilayah tertentu. Visualisasi ini sangat berguna dalam statistika lingkungan untuk melihat perbedaan spasial, misalnya distribusi polusi udara, curah hujan, atau kualitas air pada wilayah yang berbeda.

# Plot choropleth
ggplot(peta_data) +
  geom_sf(aes(fill=PM25), color="white") +
  geom_sf_text(aes(label = nm_kecamatan), size = 3, color = "white") +
  scale_fill_gradient(low="orange", high="lightblue", name="PM2.5") +
  theme_minimal() +
  labs(title="Choropleth Map PM2.5 - Kabupaten Kebumen")
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Interpretasi :

Warna peta menunjukkan tingkat polusi udara (PM2.5)

Hasilnya:

Kesimpulan :

  1. Polusi udara di Kebumen tidak merata.

  2. Wilayah pantai lebih rawan polusi, kemungkinan karena banyak aktivitas manusia (transportasi, pembakaran, atau industri kecil).

  3. Wilayah pegunungan lebih bersih karena ada banyak pohon dan udara lebih mudah menyebar.

Stacked Area Chart

Stacked Area Chart adalah grafik yang menunjukkan perkembangan nilai dari waktu ke waktu, di mana setiap kategori ditumpuk satu sama lain sehingga terlihat total keseluruhan dan juga kontribusi masing-masing bagian.

library(tidyr)
library(ggplot2)

# Tambahkan dimensi waktu dengan nama bulan
set.seed(123)
time_data <- expand.grid(
  Bulan = month.name[1:6],   # Januari - Juni
  Kecamatan = data$Kecamatan
)

# Simulasi nilai PM2.5
time_data$PM25 <- sample(20:90, nrow(time_data), replace = TRUE)

# Plot stacked area chart
library(ggplot2)

ggplot(time_data, aes(x = Bulan, y = PM25, fill = Kecamatan, group = Kecamatan)) +
  geom_area(position = "stack", color = "white", size = 0.3) +
  theme_minimal() +
  labs(
    title = "Stacked Area Chart PM2.5 per Kecamatan",
    x = "Bulan",
    y = "PM2.5"
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

interpretasi :

  1. Total PM2.5 per bulan terlihat berfluktuasi dari Januari sampai Juni. Misalnya, ada lonjakan pada Maret–April yang menunjukkan peningkatan akumulasi polusi di seluruh kecamatan.

  2. Kontribusi per kecamatan berbeda-beda: ada beberapa kecamatan yang selalu menyumbang lapisan lebih besar (misalnya warna hijau & oranye tebal), artinya mereka punya konsentrasi PM2.5 lebih tinggi dibanding kecamatan lain.

  3. Kecamatan dengan warna lapisan tipis berarti kontribusinya relatif kecil terhadap total PM2.5 kabupaten.

  4. Tren secara keseluruhan menunjukkan bahwa kualitas udara tidak stabil antar bulan, ada periode dengan polusi tinggi (puncak) dan periode lebih rendah (lembah).

Dot Plot

Adalah jenis grafik yang menampilkan data dalam bentuk titik-titik pada sumbu koordinat. Setiap titik mewakili suatu nilai untuk kategori tertentu. Grafik ini sederhana dan efektif untuk membandingkan nilai antar kategori atau kelompok, karena posisi titik memudahkan kita melihat perbedaan maupun kesamaan secara jelas.

library(ggplot2)
library(dplyr)
library(tidyr)

# Simulasi data kualitas air laut
set.seed(123)
data_pantai <- data.frame(
  Pantai = c("Pantai Menganti", "Pantai Lampon", "Pantai Suwuk", "Pantai Ayah"),
  Salinitas = c(32, 34, 30, 33),
  pH = c(8.1, 8.3, 7.9, 8.2),
  DO = c(6.5, 7.0, 6.0, 6.8),       # Dissolved Oxygen
  Nitrat = c(2.0, 1.5, 2.5, 1.8)
)

# Ubah ke format long
data_long <- data_pantai %>%
  pivot_longer(cols = -Pantai, names_to = "Indikator", values_to = "Nilai")

# Plot Dot Plot
ggplot(data_long, aes(x = Nilai, y = Pantai, color = Indikator)) +
  geom_point(size = 4) +
  theme_minimal() +
  labs(title = "Dot Plot Kualitas Air Laut per Pantai",
       x = "Nilai", y = "Pantai", color = "Indikator") +
  theme(
    axis.text.y = element_text(size = 10),
    plot.title = element_text(hjust = 0.5, face = "bold")
  )

Interpretasi :

  1. Salinitas (ungu)
  1. pH (biru)
  1. DO – Dissolved Oxygen (merah muda)
  1. Nitrat (hijau)

Kesimpulan :