Learn R Programming

geofi - Access Finnish Geospatial Data

Access Finnish Geospatial Data.

Installation and use

# install from CRAN
install.packages("geofi")

# Install development version from GitHub
remotes::install_github("ropengov/geofi")

With geofi-package you can download geospatial data on municipalities, zipcodes and population and statistical grids from Statistics Finland WFS-api. In addition, you have on-board municipality keys for aggregating municipality-level data into higher level regional distributions based Statistics Finland classification API.

Below are few examples of the data you can access using geofi. Please have a closer look at the vignettes for more comprehensive use cases.

library(geofi)
d1 <- get_municipalities(year = 2025)
d2 <- get_zipcodes(year = 2025)
d3 <- get_statistical_grid(resolution = 5)
d4 <- get_population_grid(resolution = 5)
d5 <- municipality_central_localities()

library(ggplot2)
library(dplyr)
theme_set(
  theme_minimal(base_family = "Arial") +
  theme(legend.position= "none",
        axis.text = element_blank(),
        axis.title = element_blank(),
        panel.grid = element_blank()
        )
)
p1 <- ggplot(d1, aes(fill = kunta)) + geom_sf(colour = alpha("white", 1/3)) + labs(subtitle = "municipalities")
p2 <- ggplot(d1 |> count(maakunta_code), aes(fill = maakunta_code)) + geom_sf(colour = alpha("white", 1/3)) + labs(subtitle = "Aggregated municipality data \nat region (maakunta) level \n(one of many!)")
p3 <- ggplot(d2, aes(fill = as.integer(posti_alue))) + geom_sf(colour = alpha("white", 1/3)) + labs(subtitle = "zipcodes")
p4 <- ggplot(d3, aes(fill = nro)) + geom_sf(colour = alpha("white", 1/3)) + labs(subtitle = "statistical grid")
p5 <- ggplot(d4, aes(fill = id_nro)) + geom_sf(colour = alpha("white", 1/3)) + labs(subtitle = "population grid")
p6 <- ggplot(d5, aes(color = as.integer(kuntatunnus))) + geom_sf() + labs(subtitle = "Central municipality localities")

library(patchwork)
wrap_plots(list(p1,p2,p3,p4,p5,p6), ncol = 3) + 
  patchwork::plot_annotation(title = "Spatial data in geofi-package")

Contribute

Contributions are very welcome:

Acknowledgements

Kindly cite this work as follows:

citation("geofi")
Kindly cite the geofi R package as follows:

To cite 'geofi' in publications use:

  Kainu M, Lehtomaki J, Parkkinen J, Miettinen J, Kantanen P, Vesanen
  S, Lahti L (2025). _geofi: Access Finnish Geospatial Data_.
  doi:10.32614/CRAN.package.geofi
  <https://doi.org/10.32614/CRAN.package.geofi>, R package version
  1.1.0, <https://github.com/rOpenGov/geofi>.

A BibTeX entry for LaTeX users is

  @Manual{R-geofi,
    title = {{geofi: Access Finnish Geospatial Data}},
    doi = {10.32614/CRAN.package.geofi},
    author = {Markus Kainu and Joona Lehtomaki and Juuso Parkkinen and Jani Miettinen and Pyry Kantanen and Sampo Vesanen and Leo Lahti},
    year = {2025},
    version = {1.1.0},
    note = {R package version 1.1.0},
    url = {https://github.com/rOpenGov/geofi},
  }

Many thanks for all contributors! For more info, see:
https://github.com/rOpenGov/geofi

We are grateful to all contributors. This project is part of rOpenGov.

Copy Link

Version

Install

install.packages('geofi')

Monthly Downloads

232

Version

1.1.0

License

BSD_2_clause + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Markus Kainu

Last Published

April 29th, 2025

Functions in geofi (1.1.0)

grid_etela_pohjanmaa

custom geofacet grid for Etelä-Pohjanmaa
grid_sairaanhoitop

custom geofacet grid for health care districts
grid_pohjois_savo

custom geofacet grid for Pohjois-Savo region
grid_keski_pohjanmaa

custom geofacet grid for Keski-Pohjanmaa region
grid_kymenlaakso

custom geofacet grid for Kymenlaakso region
grid_etela_savo

custom geofacet grid for Etelä-Savo
grid_lappi

custom geofacet grid for Lappi region as in 2020
municipality_central_localities

Get up-to-date municipality central locations
grid_pohjois_karjala

custom geofacet grid for Pohjois-Karjala region
municipality_key_2016

municipality_key_2016
grid_pohjois_pohjanmaa

custom geofacet grid for Pohjois-Pohjanmaa region
municipality_key_2015

municipality_key_2015
grid_varsinais_suomi

custom geofacet grid for Varsinais-Suomi region
grid_hyvinvointialue

custom geofacet grid for Wellbeing services counties
get_zipcodes

Get Finnish zip code (multi)polygons for different years.
grid_pirkanmaa

custom geofacet grid for Pirkanmaa region
grid_ahvenanmaa

custom geofacet grid for Ahvenanmaa region
grid_pohjanmaa

custom geofacet grid for Pohjanmaa region
grid_satakunta

custom geofacet grid for Satakunta region
grid_maakunta

custom geofacet grid for regions
grid_paijat_hame

custom geofacet grid for Päijät-Häme region
municipality_key

Aggregated municipality key table for years 2013-2025
grid_uusimaa

custom geofacet grid for Uusimaa region
municipality_key_2013

municipality_key_2013
municipality_key_2014

municipality_key_2014
municipality_central_localities_df

A data frame containing locations of municipalities central localities
municipality_key_2022

Municipality key table for 2022
municipality_key_2021

Municipality key table for 2021
municipality_key_2023

Municipality key table for 2023
municipality_key_2024

Municipality key table for 2024
municipality_key_2025

Municipality key table for 2025
municipality_key_2019

Municipality key table for 2019
ogc_get_statfi_statistical_grid

Retrieve Finnish Statistical Grid with Population Data
municipality_key_2020

Municipality key table for 2020
sotkadata_population

Municipality level population data from Sotkanet
ogc_get_statfi_area

Retrieve Finnish Administrative Area Polygons
municipality_key_2017

municipality_key_2017
ogc_get_maastotietokanta

Download a Collection from the Maastotietokanta (Topographic Database)
sotkadata_swedish_speaking_pop

Municipality level Swedish speaking population numbers from Sotkanet
municipality_key_2018

Municipality key table for 2018
statfi_zipcode_population

Zipcode level population data from Statistics Finland
wfs_api

WFS API
to_sf

Transform a wfs_api object into a sf object.
ogc_get_statfi_area_pop

Retrieve Finnish Administrative Area Polygons with Population Data
ogc_get_nimisto

Query Geographic Names (Nimistö) from the National Land Survey of Finland
ogc_get_maastotietokanta_collections

Fetch Maastotietokanta Collections
get_municipalities

Get Finnish municipality (multi)polygons for different years and/or scales.
convert_municipality_key_codes

Convert regional codes in on-board municipality key data sets into variable length characters
get_population_grid

fetch_ogc_api_statfi

Fetch data from Statistics Finland OGC API
get_statistical_grid

Get Statistical grid data polygons at two different resolution
get_municipality_pop

Get Number of population by Finnish municipality (multi)polygons for different years.
geocode_reverse

Reverse Geocode Geographic Locations into Finnish Place Names or Addresses
check_api_access

Check Access to Statistics Finland Geoserver APIs
geocode

Geocode Finnish Place Names or Street Addresses
grid_kainuu

custom geofacet grid for Kainuu region
fetch_ogc_api_mml

Fetch Data from OGC API (Internal)
grid_kanta_hame

custom geofacet grid for Kanta-Häme region
grid_keski_suomi

custom geofacet grid for Keski-Suomi region as in 2020
grid_etela_karjala

custom geofacet grid for Etelä-Karjala region as in 2020