Skip to content

Commit

Permalink
municipality border available, files updated accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Kainu committed Feb 11, 2025
1 parent 9627c8f commit 215d683
Show file tree
Hide file tree
Showing 24 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
"grid_varsinais_suomi"


#' Aggregated municipality key table for years 2013-2024
#' Aggregated municipality key table for years 2013-2025
#'
#' Table for aggregating municipality level data to various regional groupings
#'
Expand Down
4 changes: 2 additions & 2 deletions R/get_municipalities.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' [Statistics Finland](https://stat.fi/org/avoindata/paikkatietoaineistot/kuntapohjaiset_tilastointialueet_en.html).
#'
#' @param year A numeric for year of the administrative borders. Available are
#' 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 and 2024.
#' 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 and 2025.
#' @param scale A scale or resolution of the shape. Two options: \code{1000}
#' equals 1:1 000 000 and \code{4500} equals 1:4 500 000.
#' @param codes_as_character A logical determining if the region codes should
Expand All @@ -29,7 +29,7 @@
#' @rdname get_municipalities
#' @export

get_municipalities <- function(year = 2024, scale = 4500, codes_as_character = FALSE){
get_municipalities <- function(year = 2025, scale = 4500, codes_as_character = FALSE){

# Check if you have access to http://geo.stat.fi/geoserver/wfs
if (!check_api_access()) {
Expand Down
4 changes: 2 additions & 2 deletions R/get_zipcodes.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' Thin wrapper around Finnish zip code areas provided by
#' [Statistics Finland](https://stat.fi/tup/karttaaineistot/postinumeroalueet.html).
#'
#' @param year A numeric for year of the zipcodes. Years available 2015-2024.
#' @param year A numeric for year of the zipcodes. Years available 2015-2025.
#' @param extend_to_sea_areas A logical. Extend the data to show also the sea areas.
#'
#' @return sf object
Expand All @@ -21,7 +21,7 @@
#' @rdname get_zipcodes
#' @export

get_zipcodes <- function(year = 2023, extend_to_sea_areas = FALSE){
get_zipcodes <- function(year = 2025, extend_to_sea_areas = FALSE){

# Check if you have access to http://geo.stat.fi/geoserver/wfs
if (!check_api_access()){
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ reference:
contents:
- municipality_central_localities
- municipality_key
- municipality_key_2025
- municipality_key_2024
- municipality_key_2023
- municipality_key_2022
Expand Down
Binary file modified data/grid_ahvenanmaa.rda
Binary file not shown.
Binary file modified data/grid_etela_karjala.rda
Binary file not shown.
Binary file modified data/grid_etela_pohjanmaa.rda
Binary file not shown.
Binary file modified data/grid_kainuu.rda
Binary file not shown.
Binary file modified data/grid_kanta_hame.rda
Binary file not shown.
Binary file modified data/grid_keski_pohjanmaa.rda
Binary file not shown.
Binary file modified data/grid_keski_suomi.rda
Binary file not shown.
Binary file modified data/grid_kymenlaakso.rda
Binary file not shown.
Binary file modified data/grid_paijat_hame.rda
Binary file not shown.
Binary file modified data/grid_pirkanmaa.rda
Binary file not shown.
Binary file modified data/grid_pohjanmaa.rda
Binary file not shown.
Binary file modified data/grid_pohjois_karjala.rda
Binary file not shown.
Binary file modified data/grid_pohjois_savo.rda
Binary file not shown.
Binary file modified data/grid_satakunta.rda
Binary file not shown.
Binary file modified data/grid_uusimaa.rda
Binary file not shown.
Binary file modified data/grid_varsinais_suomi.rda
Binary file not shown.
35 changes: 18 additions & 17 deletions inst/extras/create_geofacet_grids.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ save(grid_maakunta, file = "./data/grid_maakunta.rda",
# create regions (hyvinvointialue) grid
library(geofi)
library(dplyr)
muni <- get_municipalities(year =2024)
library(sf)
muni <- get_municipalities(year =2025)
muni %>% group_by(hyvinvointialue_name_fi,hyvinvointialue_code) %>%
summarise() %>%
ungroup() -> spd
Expand Down Expand Up @@ -371,22 +372,22 @@ save(grid_uusimaa, file = "./data/grid_uusimaa.rda",
compress = "bzip2")

# use the code below as geograhical reference map
geofi::municipality_key %>%
filter(grepl("^Pohjois-Sa", mk_name)) %>%
count(kunta,kunta_name) %>%
select(-n) %>%
setNames(c("code","name")) -> tmp
write.csv(tmp, "tmp.csv", row.names = FALSE)
file.edit("./tmp.csv")
grid_design()

muni <- get_municipalities(year = 2021)
muni %>%
mutate(kunta = as.integer(sub("^0+", "", kunta))) %>%
filter(kunta %in% tmp$code) %>%
ggplot() +
geom_sf() +
geom_sf_text(aes(label = name))
# geofi::municipality_key %>%
# filter(grepl("^Pohjois-Sa", mk_name)) %>%
# count(kunta,kunta_name) %>%
# select(-n) %>%
# setNames(c("code","name")) -> tmp
# write.csv(tmp, "tmp.csv", row.names = FALSE)
# file.edit("./tmp.csv")
# grid_design()
#
# muni <- get_municipalities(year = 2021)
# muni %>%
# mutate(kunta = as.integer(sub("^0+", "", kunta))) %>%
# filter(kunta %in% tmp$code) %>%
# ggplot() +
# geom_sf() +
# geom_sf_text(aes(label = name))



Expand Down
4 changes: 2 additions & 2 deletions man/get_municipalities.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/get_zipcodes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/municipality_key.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 215d683

Please sign in to comment.