R-packages geofi for accessing Statistics Finland spatial data

research
data
R
graphics
dataviz
ropengov
Tekijä
Julkaistu

11. helmikuuta 2020

We have slowly started developing a follow-up package with ropengov-posse for gisfin-package named geofi. Package provides access to few sources of Finnish open geospatial data from R. We are focusing in administrative regions at the moment and our primary source of data is Statistics Finland and their wfs-api. You can use functions in geofi fecth data such as municipality borders, postal code areas sekä population grids.

geofi is not published in CRAN yet and you cant install it using intall.packages(). But you can install it directly from Github with remotes::install_github("ropengov/geofi") and try out the following examples. For quick access try our Shiny app at: muuankarski.shinyapps.io/geofi_selain/.

Municipalility borders

[/kode]
library(geofi)
library(ggplot2)

municipalities <- get_municipalities(year = 2020, scale = 4500)
ggplot(municipalities) + 
  geom_sf(aes(fill = as.integer(kunta))) +
  scale_fill_viridis_c()

Postal code areas

[/kode]
zipcodes <- get_zipcodes(year = 2020) 
ggplot(zipcodes) + 
  geom_sf(aes(fill = as.integer(posti_alue)), color = alpha("white", 1/3)) +
  scale_fill_viridis_c()

Population grids

[/kode]
pop_grid <- get_population_grid(year = 2018, resolution = 5)
ggplot(pop_grid) + 
  geom_sf(aes(fill = objectid), color = alpha("white", 1/3)) +
  scale_fill_viridis_c()

Regions (maakunnant), health care districts (sairaanhoitopiirit) and many more regional breakdowns are based on municipality divide. get_municipalities()-function returns data containing these attribute variables (year 2020), that you can use to aggregate from municipality level upwards.

[/kode]
library(dplyr)
municipalities <- get_municipalities(year = 2019, scale = 4500)
regions <- municipalities %>% 
  group_by(maakunta_name_fi) %>% summarise()
ggplot(regions) + 
  geom_sf(aes(fill = maakunta_name_fi)) +
  scale_fill_viridis_d()

Take a look at the Github-site and join us!

Uudelleenkäyttö

Viittaus

BibTeX-viittaus:
@online{kainu2020,
  author = {Kainu, Markus},
  title = {R-packages `geofi` for accessing Statistics Finland spatial
    data},
  date = {2020-02-11},
  url = {https://markuskainu.fi/posts/2020-02-06-geofi-pkg-in-development/},
  langid = {fi}
}
Viitatkaa tähän teokseen seuraavasti:
Kainu, Markus. 2020. “R-packages `geofi` for accessing Statistics Finland spatial data.” February 11, 2020. https://markuskainu.fi/posts/2020-02-06-geofi-pkg-in-development/.