I am plotting springs within a place "Christchurch", however, the place does not appear when I run it only the spring locations themselves.
# packages
library(sf)
library(tmap)
library(tidyverse)
library(rmapshaper)
library(dplyr)
library(units)
library(terra)
library(rmapshaper)
library(tidyr)
library(tmaptools)
library(tibble)
library(tidygeocoder)
library(ggplot2) # plotting spatial data
library(ggsn) # north arrow and scale bar for ggplot2
library(mapsf) # plotting spatial data
library(ggspatial)
library(ggthemes)
library(nzcensr)
library(ggrepel)
# reading spatial springs
springs_geo <- st_read("Spring_Locations.geojson")
# springs csv
springs_csv <- read.csv("Spring_Locations.csv")
# reading TA's
TA <- st_read("territorial-authority-2021-generalised.gpkg")
# transforming spring projection
springs_geo <- springs_geo %>% st_transform(crs = "EPSG:2193")
springs_csv <- springs_csv %>% transform(crs = "EPSG:2193")
# selecting variables and changing names as we go
TA <- TA %>% select(TA_code = TA2021_V1_00, TA_name = TA2021_V1_00_NAME, land_area_sq_km = LAND_AREA_SQ_KM,
area_sq_km = AREA_SQ_KM, shape_length = Shape_Length, geometry = geom)
# filtering greater CHCH springs geo only
springs_geo_chch <- springs_geo %>%
st_filter(TA %>% filter(TA_name == "Christchurch City"))
# geocoding
springs_chch_loc <- geocode_OSM(springs_chch$ROAD_OR_STREET, projection = 4326, as.sf = TRUE)
springs_chch_loc <- springs_chch_loc %>% st_transform(crs = "EPSG:2193")
tmap_mode("plot")
tm_shape(shp = springs_geo_chch,
bbox = "Christchurch") +
tm_dots(col = "red",
title = "Christchurch Spring Locations",
alpha = 1,
size = 0.2) +
tm_scale_bar(position = c("right", "bottom"),
breaks = c(0,1,2)) +
tm_credits("Data: Canterbury Regional Council, 2016",
position=c("right", "bottom"),
size = 0.8) +
tm_compass(position = c("right", "top"),
size = 1.5,
show.labels = T,
color.light = "black") +
tm_layout(bg.color = "lightcyan",
frame = T,
legend.position = c("left","top"),
title = "Locations of Springs in Christchurch",
title.size = 1.5,
title.fontface = "bold",
legend.title.size = 0.8,
legend.text.size = 0.6)
Would this be due to a geocoding issue, I am new to programming so am unsure of this.