Kiama Coastal walk

R
rinat
mapview
South Coast
NSW
Author

José R. Ferrer-Paris

Published

May 25, 2025

Modified

August 30, 2025

Tools and Libraries

I will be using R with the following selection of libraries in this blog post:

library(rinat)
library(dplyr)
library(lubridate)
library(sf)
library(mapview)
library(leafpop)
library(DT)
  • rinat: Access iNaturalist data with R.

  • dplyr: A Grammar of Data Manipulation.

  • DT: An R interface to the DataTables library

I use the library here to manage relative paths of the project:

here::i_am("regions/Kiama-walk.qmd")

I save the downloaded inat data into this data folder at the root of the project folder:

if (!dir.exists(here::here("data")))
    dir.create(here::here("data"))
inat_obs_data <- here::here("data", "inat-obs.rds")

This will query all the observations from my iNaturalist user. I will save this to a data folder:

if (file.exists(inat_obs_data)) {
    user_obs <- readRDS(inat_obs_data)
} else {
    user_obs <- get_inat_obs_user("NeoMapas",maxresults = 5000) |> 
        mutate(dts=date(datetime), year=year(dts), month=month(dts))
    saveRDS(user_obs, inat_obs_data)
}

I can make this object spatially explicit using the function st_to_sf from package sf:

user_obs_xy <- st_as_sf(user_obs,coords=c("longitude","latitude"), crs=4326)

For this post, I am focusing on the observation made on the 9 March 2025:

kiama_walk_obs <- filter(user_obs_xy, 
  dts %in% c("2025-02-08", "2025-02-09", "2025-02-10"))

This is the number of observations for that day:

nrow(kiama_walk_obs)
[1] 61

And this is the approximate number of species (or other taxa) included in those observations:

n_distinct(kiama_walk_obs$species_guess)
[1] 48

Table of observations

We can create a table of observations:

st_drop_geometry(kiama_walk_obs) |> 
  select(scientific_name, common_name, quality_grade, url) |>
  mutate(`url` = 
    sprintf('<a href="%s" target="_blank">iNat link</a>', url)) |> 
  datatable(style='bootstrap4', escape = FALSE) |>
  formatStyle(c('common_name', 'quality_grade', 'url'),  
    color = 'maroon', backgroundColor = 'mistyrose') |>
  formatStyle('scientific_name', 
    color = 'maroon', backgroundColor = 'mistyrose', fontStyle = 'italic')

Here I am using the datatable function from package DT, and setting the style to bootstrap4 to match the style of this website.

Map of locations

A quick map with the default image of each observation can be made with mapview:

mapview(kiama_walk_obs,
    map.types = c("OpenStreetMap.DE", "Esri.WorldImagery"),
    layer.name = c("Kiama coastal walk"),
    popup =
     popupImage(kiama_walk_obs$image_url, src = "remote"))

That’s fantastic!

Session info

sessionInfo()
R version 4.5.0 (2025-04-11)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.6.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

time zone: Australia/Sydney
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DT_0.33         leafpop_0.1.0   mapview_2.11.2  sf_1.0-21      
[5] lubridate_1.9.4 dplyr_1.1.4     rinat_0.1.9    

loaded via a namespace (and not attached):
 [1] gtable_0.3.6            xfun_0.52               ggplot2_3.5.2          
 [4] raster_3.6-32           htmlwidgets_1.6.4       lattice_0.22-7         
 [7] leaflet.providers_2.0.0 vctrs_0.6.5             tools_4.5.0            
[10] crosstalk_1.2.1         generics_0.1.4          stats4_4.5.0           
[13] curl_6.4.0              tibble_3.3.0            proxy_0.4-27           
[16] pkgconfig_2.0.3         KernSmooth_2.23-26      satellite_1.0.5        
[19] RColorBrewer_1.1-3      leaflet_2.2.2           uuid_1.2-1             
[22] lifecycle_1.0.4         compiler_4.5.0          farver_2.1.2           
[25] textshaping_1.0.1       terra_1.8-60            codetools_0.2-20       
[28] htmltools_0.5.8.1       maps_3.4.3              class_7.3-23           
[31] yaml_2.3.10             pillar_1.11.0           jquerylib_0.1.4        
[34] classInt_0.4-11         brew_1.0-10             tidyselect_1.2.1       
[37] digest_0.6.37           rprojroot_2.0.4         fastmap_1.2.0          
[40] grid_4.5.0              here_1.0.1              colorspace_2.1-1       
[43] cli_3.6.5               magrittr_2.0.3          base64enc_0.1-3        
[46] dichromat_2.0-0.1       leafem_0.2.4            e1071_1.7-16           
[49] withr_3.0.2             scales_1.4.0            sp_2.2-0               
[52] timechange_0.3.0        rmarkdown_2.29          httr_1.4.7             
[55] png_0.1-8               evaluate_1.0.3          knitr_1.50             
[58] rlang_1.1.6             Rcpp_1.1.0              glue_1.8.0             
[61] DBI_1.2.3               svglite_2.2.1           jsonlite_2.0.0         
[64] R6_2.6.1                plyr_1.8.9              systemfonts_1.2.3      
[67] units_0.8-7