| Title: | Access Finnish Geospatial Data |
|---|---|
| Description: | Designed to simplify geospatial data access from the Statistics Finland Web Feature Service API <https://geo.stat.fi/geoserver/index.html>, the geofi package offers researchers and analysts a set of tools to obtain and harmonize administrative spatial data for a wide range of applications, from urban planning to environmental research. The package contains annually updated time series of municipality key datasets that can be used for data aggregation and language translations. |
| Authors: | Markus Kainu [aut, cre] (ORCID: <https://orcid.org/0000-0003-1376-503X>), Joona Lehtomaki [aut] (ORCID: <https://orcid.org/0000-0002-7891-0843>), Juuso Parkkinen [ctb] (ORCID: <https://orcid.org/0000-0002-7818-5901>), Jani Miettinen [ctb], Pyry Kantanen [ctb], Sampo Vesanen [ctb], Leo Lahti [aut] (ORCID: <https://orcid.org/0000-0001-5537-637X>) |
| Maintainer: | Markus Kainu <[email protected]> |
| License: | BSD_2_clause + file LICENSE |
| Version: | 1.2.1 |
| Built: | 2026-06-01 09:49:38 UTC |
| Source: | https://github.com/rOpenGov/geofi |
Tests whether R can access resources at Statistics Finland's geoserver APIs, specifically the WFS (Web Feature Service) or OGC API. This internal function is used to verify connectivity before making API requests.
check_api_access(which_api = "statfi_wfs")check_api_access(which_api = "statfi_wfs")
which_api |
Character. The API to check. Must be one of:
|
This function sends a lightweight HTTP request to the specified API endpoint
to check for accessibility. It uses httr2 for robust HTTP handling and
retries transient network failures up to 3 times. The function is intended for
internal use within the package to ensure API connectivity before executing
data retrieval operations.
Logical. Returns TRUE if the API is accessible (HTTP status 200),
FALSE otherwise. Issues a warning if the request fails due to network
issues or non-200 status codes.
Markus Kainu [email protected]
## Not run: check_api_access() # Check WFS API check_api_access("statfi_ogc") # Check OGC API ## End(Not run)## Not run: check_api_access() # Check WFS API check_api_access("statfi_ogc") # Check OGC API ## End(Not run)
Statistics Finland provides numerical codes of regions as two or three digit characters. By default, those are converted to integers by geofi for convenience, but can be converted back using this function.
convert_municipality_key_codes(muni_key = geofi::municipality_key)convert_municipality_key_codes(muni_key = geofi::municipality_key)
muni_key |
a municipality key from geofi-package |
tibble with codes converted to variable length characters as provided by Statistics Finland
Markus Kainu [email protected], Pyry Kantanen
## Not run: convert_municipality_key_codes(muni_key = geofi::municipality_key) ## End(Not run)## Not run: convert_municipality_key_codes(muni_key = geofi::municipality_key) ## End(Not run)
Geocodes Finnish place names or street addresses using the National Land Survey of Finland (NLS) geocoding REST API. This function converts textual location descriptions into spatial coordinates.
geocode( search_string, source = "interpolated-road-addresses", crs = 3067, lang = "fi", size = NULL, options = NULL, api_key = getOption("geofi_mml_api_key") )geocode( search_string, source = "interpolated-road-addresses", crs = 3067, lang = "fi", size = NULL, options = NULL, api_key = getOption("geofi_mml_api_key") )
search_string |
Character. The place name or street address to geocode
(e.g., |
source |
Character. The data source to search in. Must be one of:
|
crs |
Character. The coordinate reference system (CRS) for the
output data, specified as an EPSG code. Must be one of |
lang |
Character. The language for the API response labels. Must be one of
|
size |
Numeric or NULL. The maximum number of results to return. Must be a
positive integer. If |
options |
Character or NULL. Additional options to pass to the API, specified
as a single string (e.g., |
api_key |
Character. API key for authenticating with the NLS geocoding API.
Defaults to the value stored in |
This function uses the NLS geocoding REST API to convert place names or street addresses into spatial coordinates. It supports multiple data sources, including interpolated road addresses, geographic names, and cadastral units. The function includes robust error handling:
Retries failed requests up to 3 times for transient network issues.
Handles HTTP errors and rate limits (HTTP 429).
Validates inputs to prevent common errors.
An sf object containing the geocoded locations as points in the
specified crs. If no results are found, a warning is issued, and
an empty sf object is returned.
Markus Kainu [email protected]
geocode_reverse for reverse geocoding.
https://www.maanmittauslaitos.fi/en/rajapinnat/api-avaimen-ohje for
instructions on obtaining an API key.
https://www.maanmittauslaitos.fi/kartat-ja-paikkatieto/aineistot-ja-rajapinnat/paikkatietojen-rajapintapalvelut/geokoodauspalvelu
for more information on the NLS geocoding API.
## Not run: # Set your API key options(geofi_mml_api_key = "your_api_key_here") # Geocode a place name locations <- geocode(search_string = "Suomenlinna", source = "geographic-names") print(locations) # Geocode a street address with a custom size and output CRS addresses <- geocode( search_string = "Mannerheimintie 100, Helsinki", source = "addresses", crs = "EPSG:4326", size = 5 ) print(addresses) ## End(Not run)## Not run: # Set your API key options(geofi_mml_api_key = "your_api_key_here") # Geocode a place name locations <- geocode(search_string = "Suomenlinna", source = "geographic-names") print(locations) # Geocode a street address with a custom size and output CRS addresses <- geocode( search_string = "Mannerheimintie 100, Helsinki", source = "addresses", crs = "EPSG:4326", size = 5 ) print(addresses) ## End(Not run)
Reverse geocodes geographic coordinates into Finnish place names or street addresses using the National Land Survey of Finland (NLS) geocoding REST API. This function converts spatial points into textual location descriptions.
geocode_reverse( point, boundary_circle_radius = NULL, size = NULL, layers = NULL, sources = NULL, return = "sf", api_key = getOption("geofi_mml_api_key") )geocode_reverse( point, boundary_circle_radius = NULL, size = NULL, layers = NULL, sources = NULL, return = "sf", api_key = getOption("geofi_mml_api_key") )
point |
An |
boundary_circle_radius |
Numeric or NULL. The radius (in meters) of a
circular boundary around each point to limit the search area. Must be a
positive number. If |
size |
Numeric or NULL. The maximum number of results to return per point.
Must be a positive integer. If |
layers |
Character or NULL. The layers to include in the search, specified
as a comma-separated string (e.g., |
sources |
Character or NULL. The data sources to search in, specified as a
comma-separated string (e.g., |
return |
Character. The format of the returned data. Must be one of
|
api_key |
Character. API key for authenticating with the NLS geocoding API.
Defaults to the value stored in |
This function uses the NLS geocoding REST API to convert geographic coordinates into place names or street addresses. It supports multiple points in a single call and allows filtering by search radius, layers, sources, and country. The function includes robust error handling:
Retries failed requests up to 3 times for transient network issues.
Handles HTTP errors and rate limits (HTTP 429).
Validates inputs to prevent common errors.
If return="sf", an sf object containing the reverse
geocoded locations as points in EPSG:4326 (WGS84) CRS. If return="json",
a list of raw JSON responses from the API. If no results are found for a point,
a warning is issued, and that point may be omitted from the results.
Markus Kainu [email protected]
geocode for forward geocoding.
https://www.maanmittauslaitos.fi/en/rajapinnat/api-avaimen-ohje for
instructions on obtaining an API key.
https://www.maanmittauslaitos.fi/kartat-ja-paikkatieto/aineistot-ja-rajapinnat/paikkatietojen-rajapintapalvelut/geokoodauspalvelu
for more information on the NLS geocoding API.
## Not run: # Set your API key options(geofi_mml_api_key = "your_api_key_here") # Create a point for Suomenlinna (in EPSG:4326) # Reverse geocode to get place names print(places) # Reverse geocode with a search radius and return raw JSON places_json <- geocode_reverse( point = suomenlinna, boundary_circle_radius = 1000, return = "json" ) print(places_json) ## End(Not run)## Not run: # Set your API key options(geofi_mml_api_key = "your_api_key_here") # Create a point for Suomenlinna (in EPSG:4326) # Reverse geocode to get place names print(places) # Reverse geocode with a search radius and return raw JSON places_json <- geocode_reverse( point = suomenlinna, boundary_circle_radius = 1000, return = "json" ) print(places_json) ## End(Not run)
Thin wrapper around Finnish zip code areas provided by Statistics Finland.
get_municipalities(year = 2026, scale = 4500, codes_as_character = FALSE)get_municipalities(year = 2026, scale = 4500, codes_as_character = FALSE)
year |
A numeric for year of the administrative borders. Available are 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 and 2026. |
scale |
A scale or resolution of the shape. Two options: |
codes_as_character |
A logical determining if the region codes should be returned as strings of equal width as originally provided by Statistics Finland instead of integers. |
sf object
Markus Kainu [email protected], Joona Lehtomäki [email protected]
## Not run: f <- get_municipalities(year=2016, scale = 4500) plot(f) ## End(Not run)## Not run: f <- get_municipalities(year=2016, scale = 4500) plot(f) ## End(Not run)
Thin wrapper around Finnish zip code areas provided by Statistics Finland.
get_municipality_pop(year = 2022, codes_as_character = FALSE)get_municipality_pop(year = 2022, codes_as_character = FALSE)
year |
A numeric for year of the administrative borders. Available are 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 and 2022. |
codes_as_character |
A logical determining if the region codes should be returned as strings of equal width as originally provided by Statistics Finland instead of integers. |
The number of population on the last day of the reference year combined with municipality borders from year after. Calling the function with year = 2019 returns population data from 2019-12-31 with spatial data from 2020.
The statistical variables in the data are: total population (vaesto), share of the total population (vaesto_p), number of men (miehet), men's share of the population in an area (miehet_p) and women (naiset), women's share (naiset_p), those aged under 15: number (ika_0_14), share (ika_0_14p), those aged 15 to 64: number (ika_15_64), share (ika_15_64p), and aged 65 or over: number (ika_65_), share (ika_65_p).
sf object
Markus Kainu [email protected], Joona Lehtomäki [email protected]
## Not run: f <- get_municipality_pop(year=2020) plot(f) ## End(Not run)## Not run: f <- get_municipality_pop(year=2020) plot(f) ## End(Not run)
Get Finnish Population grid in two different resolutions for years 2010-2022 Thin wrapper around Finnish population grid data provided by Statistics Finland.
get_population_grid(year = 2022, resolution = 5)get_population_grid(year = 2022, resolution = 5)
year |
A numeric for year of the population grid. Years available 2005 and 2010-2022. |
resolution |
1 (1km x 1km) or 5 (5km x 5km) |
More information about the dataset from Paikkatietohakemisto
sf object
Markus Kainu [email protected], Joona Lehtomäki [email protected]
## Not run: f <- get_population_grid(year=2017) plot(f) ## End(Not run)## Not run: f <- get_population_grid(year=2017) plot(f) ## End(Not run)
Thin wrapper around Finnish statistical grid data provided by Statistics Finland.
get_statistical_grid(resolution = 5, auxiliary_data = FALSE)get_statistical_grid(resolution = 5, auxiliary_data = FALSE)
resolution |
integer 1 (1km x 1km) or 5 (5km x 5km) |
auxiliary_data |
logical Whether to include auxiliary data containing municipality membership data. Default |
sf object
Markus Kainu [email protected], Joona Lehtomäki [email protected]
## Not run: f <- get_statistical_grid(resolution = 5, auxiliary_data = FALSE) plot(f) ## End(Not run)## Not run: f <- get_statistical_grid(resolution = 5, auxiliary_data = FALSE) plot(f) ## End(Not run)
Thin wrapper around Finnish zip code areas provided by Statistics Finland.
get_zipcodes(year = 2025, extend_to_sea_areas = FALSE)get_zipcodes(year = 2025, extend_to_sea_areas = FALSE)
year |
A numeric for year of the zipcodes. Years available 2015-2025. |
extend_to_sea_areas |
A logical. Extend the data to show also the sea areas. |
sf object
Markus Kainu [email protected], Joona Lehtomäki [email protected]
## Not run: f <- get_zipcodes(year=2022) plot(f) ## End(Not run)## Not run: f <- get_zipcodes(year=2022) plot(f) ## End(Not run)
Grid table to be used with ggplot2 and geofacet
grid_ahvenanmaagrid_ahvenanmaa
A data frame with 16 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_etela_karjalagrid_etela_karjala
A data frame with 9 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_etela_pohjanmaagrid_etela_pohjanmaa
A data frame with 18 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_etela_savogrid_etela_savo
A data frame with 11 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_hyvinvointialuegrid_hyvinvointialue
A data frame with 23 rows and 4 variables:
Wellbeing services county name (hyvinvointialue) in Finnish
Wellbeing services counties code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_kainuugrid_kainuu
A data frame with 8 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_kanta_hamegrid_kanta_hame
A data frame with 11 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_keski_pohjanmaagrid_keski_pohjanmaa
A data frame with 8 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_keski_suomigrid_keski_suomi
A data frame with 22 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_kymenlaaksogrid_kymenlaakso
A data frame with 6 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_lappigrid_lappi
A data frame with 21 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_maakuntagrid_maakunta
A data frame with 19 rows and 4 variables:
Region name (maakunta) in Finnish
Region code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_paijat_hamegrid_paijat_hame
A data frame with 10 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_pirkanmaagrid_pirkanmaa
A data frame with 23 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_pohjanmaagrid_pohjanmaa
A data frame with 14 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_pohjois_karjalagrid_pohjois_karjala
A data frame with 13 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_pohjois_pohjanmaagrid_pohjois_pohjanmaa
A data frame with 30 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_pohjois_savogrid_pohjois_savo
A data frame with 19 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_sairaanhoitopgrid_sairaanhoitop
A data frame with 21 rows and 4 variables:
District name (Sairaanhoitopiiri) in Finnish
District code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_satakuntagrid_satakunta
A data frame with 16 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_uusimaagrid_uusimaa
A data frame with 26 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Grid table to be used with ggplot2 and geofacet
grid_varsinais_suomigrid_varsinais_suomi
A data frame with 27 rows and 4 variables:
Municipality name (kunta) in Finnish
Municipality code
Vertical location in grid
Horizontal location in grid
Convert municipality central locations from on-board data frame into a sf point data
municipality_central_localities()municipality_central_localities()
sf object
Markus Kainu [email protected]
## Not run: f <- municipality_central_localities() plot(f) ## End(Not run)## Not run: f <- municipality_central_localities() plot(f) ## End(Not run)
Data is extracted from latest version (April 2025) of Topographic Database (Maastotietokanta) by National Land Survey of Finland (Maanmittauslaitos)
municipality_central_localities_dfmunicipality_central_localities_df
A data.frame with 309 rows and 19 variables:
mtk_id
location precision
data source
start date
Municipality name
direction
dx
dy
kohderyhmä
kohdeluokka
ladontatunnus
kirjasintyyppikoodi
kirjasinkoko
kirjasinvarikoodi
kirjasinkallistuskulma
kirjasinvalyskerroin
municipality code
longitude
latitude
Table for aggregating municipality level data to various regional groupings
municipality_keymunicipality_key
A data frame with 4057 rows and 89 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
ely_code
ely_name_fi
ely_name_sv
ely_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
tyossakayntial_code
tyossakayntial_name_fi
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
sairaanhoitop_code
sairaanhoitop_name_fi
sairaanhoitop_name_sv
sairaanhoitop_name_en
nuts1_code
nuts1_name_fi
nuts1_name_sv
nuts1_name_en
nuts2_code
nuts2_name_fi
nuts2_name_sv
nuts2_name_en
nuts3_code
nuts3_name_fi
nuts3_name_sv
nuts3_name_en
vaalipiiri_code
vaalipiiri_name_fi
vaalipiiri_name_sv
vaalipiiri_name_en
hyvinvointialue_code
hyvinvointialue_name_fi
hyvinvointialue_name_sv
hyvinvointialue_name_en
tyossakayntial_name_sv
tyossakayntial_name_en
yhteistyoalue_code
yhteistyoalue_name_fi
yhteistyoalue_name_sv
yhteistyoalue_name_en
tyollisyysalue_code
tyollisyysalue_name_fi
tyollisyysalue_name_sv
tyollisyysalue_name_en
municipality_code
kunta_name
name_fi
name_sv
kela_palvelualue_name_fi
kela_palvelualue_code
kela_palvelualue_name_sv
kela_palvelualue_name_en
kela_asumistukialue_name_fi
kela_asumistukialue_code
kela_asumistukialue_name_sv
kela_asumistukialue_name_en
erva_code
erva_name_en
erva_name_fi
erva_name_sv
evk_code
evk_name_en
evk_name_fi
evk_name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2013municipality_key_2013
A data frame with 320 rows and 35 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
tyossakayntial_code
tyossakayntial_name_fi
ely_code
ely_name_fi
ely_name_sv
ely_name_en
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
year
municipality_code
kunta_name
name_fi
name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2014municipality_key_2014
A data frame with 320 rows and 39 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
tyossakayntial_code
tyossakayntial_name_fi
ely_code
ely_name_fi
ely_name_sv
ely_name_en
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
municipality_code
kunta_name
name_fi
name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2015municipality_key_2015
A data frame with 317 rows and 39 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
tyossakayntial_code
tyossakayntial_name_fi
ely_code
ely_name_fi
ely_name_sv
ely_name_en
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
municipality_code
kunta_name
name_fi
name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2016municipality_key_2016
A data frame with 313 rows and 39 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
tyossakayntial_code
tyossakayntial_name_fi
ely_code
ely_name_fi
ely_name_sv
ely_name_en
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
municipality_code
kunta_name
name_fi
name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2017municipality_key_2017
A data frame with 311 rows and 55 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
tyossakayntial_code
tyossakayntial_name_fi
ely_code
ely_name_fi
ely_name_sv
ely_name_en
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
sairaanhoitop_code
sairaanhoitop_name_fi
sairaanhoitop_name_sv
sairaanhoitop_name_en
nuts1_code
nuts1_name_fi
nuts1_name_sv
nuts1_name_en
nuts2_code
nuts2_name_fi
nuts2_name_sv
nuts2_name_en
nuts3_code
nuts3_name_fi
nuts3_name_sv
nuts3_name_en
municipality_code
kunta_name
name_fi
name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2018municipality_key_2018
A data frame with 311 rows and 59 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
ely_code
ely_name_fi
ely_name_sv
ely_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
tyossakayntial_code
tyossakayntial_name_fi
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
sairaanhoitop_code
sairaanhoitop_name_fi
sairaanhoitop_name_sv
sairaanhoitop_name_en
nuts1_code
nuts1_name_fi
nuts1_name_sv
nuts1_name_en
nuts2_code
nuts2_name_fi
nuts2_name_sv
nuts2_name_en
nuts3_code
nuts3_name_fi
nuts3_name_sv
nuts3_name_en
municipality_code
kunta_name
name_fi
name_sv
hyvinvointialue_code
hyvinvointialue_name_fi
hyvinvointialue_name_sv
hyvinvointialue_name_en
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2019municipality_key_2019
A data frame with 311 rows and 63 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
ely_code
ely_name_fi
ely_name_sv
ely_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
tyossakayntial_code
tyossakayntial_name_fi
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
sairaanhoitop_code
sairaanhoitop_name_fi
sairaanhoitop_name_sv
sairaanhoitop_name_en
nuts1_code
nuts1_name_fi
nuts1_name_sv
nuts1_name_en
nuts2_code
nuts2_name_fi
nuts2_name_sv
nuts2_name_en
nuts3_code
nuts3_name_fi
nuts3_name_sv
nuts3_name_en
vaalipiiri_code
vaalipiiri_name_fi
vaalipiiri_name_sv
vaalipiiri_name_en
municipality_code
kunta_name
name_fi
name_sv
hyvinvointialue_code
hyvinvointialue_name_fi
hyvinvointialue_name_sv
hyvinvointialue_name_en
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2020municipality_key_2020
A data frame with 310 rows and 67 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
ely_code
ely_name_fi
ely_name_sv
ely_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
tyossakayntial_code
tyossakayntial_name_fi
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
sairaanhoitop_code
sairaanhoitop_name_fi
sairaanhoitop_name_sv
sairaanhoitop_name_en
nuts1_code
nuts1_name_fi
nuts1_name_sv
nuts1_name_en
nuts2_code
nuts2_name_fi
nuts2_name_sv
nuts2_name_en
nuts3_code
nuts3_name_fi
nuts3_name_sv
nuts3_name_en
vaalipiiri_code
vaalipiiri_name_fi
vaalipiiri_name_sv
vaalipiiri_name_en
municipality_code
kunta_name
name_fi
name_sv
hyvinvointialue_code
hyvinvointialue_name_fi
hyvinvointialue_name_sv
hyvinvointialue_name_en
erva_code
erva_name_en
erva_name_fi
erva_name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2021municipality_key_2021
A data frame with 309 rows and 63 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
ely_code
ely_name_fi
ely_name_sv
ely_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
tyossakayntial_code
tyossakayntial_name_fi
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
sairaanhoitop_code
sairaanhoitop_name_fi
sairaanhoitop_name_sv
sairaanhoitop_name_en
nuts1_code
nuts1_name_fi
nuts1_name_sv
nuts1_name_en
nuts2_code
nuts2_name_fi
nuts2_name_sv
nuts2_name_en
nuts3_code
nuts3_name_fi
nuts3_name_sv
nuts3_name_en
vaalipiiri_code
vaalipiiri_name_fi
vaalipiiri_name_sv
vaalipiiri_name_en
hyvinvointialue_code
hyvinvointialue_name_fi
hyvinvointialue_name_sv
hyvinvointialue_name_en
municipality_code
kunta_name
name_fi
name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2022municipality_key_2022
A data frame with 309 rows and 65 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
ely_code
ely_name_fi
ely_name_sv
ely_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
tyossakayntial_code
tyossakayntial_name_fi
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
sairaanhoitop_code
sairaanhoitop_name_fi
sairaanhoitop_name_sv
sairaanhoitop_name_en
nuts1_code
nuts1_name_fi
nuts1_name_sv
nuts1_name_en
nuts2_code
nuts2_name_fi
nuts2_name_sv
nuts2_name_en
nuts3_code
nuts3_name_fi
nuts3_name_sv
nuts3_name_en
vaalipiiri_code
vaalipiiri_name_fi
vaalipiiri_name_sv
vaalipiiri_name_en
hyvinvointialue_code
hyvinvointialue_name_fi
hyvinvointialue_name_sv
hyvinvointialue_name_en
tyossakayntial_name_sv
tyossakayntial_name_en
municipality_code
kunta_name
name_fi
name_sv
erva_code
erva_name_en
erva_name_fi
erva_name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2023municipality_key_2023
A data frame with 309 rows and 74 variables:
Municipality code
Municipality name in Finnish
Municipality name in Swedish
Municipality name in English
Tilastollinen kuntaryhmitys (Statistical grouping) code
Tilastollinen kuntaryhmitys (Statistical grouping) name in Finnish
Tilastollinen kuntaryhmitys (Statistical grouping) name in Swedish
Tilastollinen kuntaryhmitys (Statistical grouping) name in English
Aluehallintovirasto code (Regional State Administrative Agencies)
Aluehallintovirasto name in Finnish (Regional State Administrative Agencies)
Aluehallintovirasto name in Finnish (Regional State Administrative Agencies)
Aluehallintovirasto name in Finnish (Regional State Administrative Agencies)
Elinkeino-, liikenne- ja ympäristökeskuksen code (Centre for Economic Development, Transport and the Environment)
Elinkeino-, liikenne- ja ympäristökeskuksen name in Finnish (Centre for Economic Development, Transport and the Environment)
Elinkeino-, liikenne- ja ympäristökeskuksen name in Swedish (Centre for Economic Development, Transport and the Environment)
Elinkeino-, liikenne- ja ympäristökeskuksen name in English (Centre for Economic Development, Transport and the Environment)
Maakunta code (Regions of Finland)
Maakunta name in Finnish (Regions of Finland)
Maakunta name in Swedish (Regions of Finland)
Maakunta name in English (Regions of Finland)
Kielisuhde code (Language distribution 2020)
Kielisuhde name in Finnish (Language distribution 2020)
Kielisuhde name in Swedish (Language distribution 2020)
Kielisuhde name in English (Language distribution 2020)
Seutukunta code (Sub-regions of Finland)
Seutukunta name in Finnish (Sub-regions of Finland)
Seutukunta name in Swedish (Sub-regions of Finland)
Seutukunta name in English (Sub-regions of Finland)
data year
Suuralue code
Suuralueen nimi in Finnish (Large Areas)
Suuralueen nimi in Swedish (Large Areas)
Suuralueen nimi in English (Large Areas)
NUTS 2016 classification code (level 1)
NUTS 2016 classification name in Finnish (level 1)
NUTS 2016 classification name in Swedish (level 1)
NUTS 2016 classification name in English (level 1)
NUTS 2016 classification code (level 2)
NUTS 2016 classification name in Finnish (level 2)
NUTS 2016 classification name in Swedish (level 2)
nuts2_name_en
NUTS 2016 classification code (level 2)
NUTS 2016 classification name in Finnish (level 3)
NUTS 2016 classification name in Swedish (level 3)
NUTS 2016 classification name in English (level 3)
Vaalipiiri code (Constituencies)
Vaalipiiri name in Finnish (Constituencies)
Vaalipiiri name in Swedish (Constituencies)
Vaalipiiri name in English (Constituencies)
Municipality code
Municipality name in Finnish
Municipality name in Finnish
Municipality name in Finnish
Sosiaali- ja terveydenhuollon yhteistyöalueiden koodi (Collaborative areas for healthcare and social welfare codes)
Sosiaali- ja terveydenhuollon yhteistyöalueet
Samarbetsområden för social- och hälsovården
Collaborative areas for healthcare and social welfare
Työssäkäyntialue code
Työssäkäyntialue name in Finnish
Työssäkäyntialue name in Swedish
Työssäkäyntialue name in English
Hyvinvointialue name in Finnish (Wellbeing services counties)
Hyvinvointialue name in Swedish (Wellbeing services counties)
Hyvinvointialue name in English (Wellbeing services counties)
Hyvinvointialue code (Wellbeing services counties)
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2024municipality_key_2024
A data frame with 309 rows and 61 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
ely_code
ely_name_fi
ely_name_sv
ely_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
nuts1_code
nuts1_name_fi
nuts1_name_sv
nuts1_name_en
nuts2_code
nuts2_name_fi
nuts2_name_sv
nuts2_name_en
nuts3_code
nuts3_name_fi
nuts3_name_sv
nuts3_name_en
vaalipiiri_code
vaalipiiri_name_fi
vaalipiiri_name_sv
vaalipiiri_name_en
hyvinvointialue_code
hyvinvointialue_name_fi
hyvinvointialue_name_sv
hyvinvointialue_name_en
yhteistyoalue_code
yhteistyoalue_name_fi
yhteistyoalue_name_sv
yhteistyoalue_name_en
municipality_code
kunta_name
name_fi
name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2025municipality_key_2025
A data frame with 308 rows and 65 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
avi_code
avi_name_fi
avi_name_sv
avi_name_en
ely_code
ely_name_fi
ely_name_sv
ely_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
nuts1_code
nuts1_name_fi
nuts1_name_sv
nuts1_name_en
nuts2_code
nuts2_name_fi
nuts2_name_sv
nuts2_name_en
nuts3_code
nuts3_name_fi
nuts3_name_sv
nuts3_name_en
vaalipiiri_code
vaalipiiri_name_fi
vaalipiiri_name_sv
vaalipiiri_name_en
hyvinvointialue_code
hyvinvointialue_name_fi
hyvinvointialue_name_sv
hyvinvointialue_name_en
yhteistyoalue_code
yhteistyoalue_name_fi
yhteistyoalue_name_sv
yhteistyoalue_name_en
tyollisyysalue_code
tyollisyysalue_name_fi
tyollisyysalue_name_sv
tyollisyysalue_name_en
municipality_code
kunta_name
name_fi
name_sv
https://data.stat.fi/api/classifications/v2/classifications
Table for aggregating municipality level data to various regional groupings
municipality_key_2026municipality_key_2026
A data frame with 308 rows and 69 variables:
kunta
municipality_name_fi
municipality_name_sv
municipality_name_en
kielisuhde_code
kielisuhde_name_fi
kielisuhde_name_sv
kielisuhde_name_en
kuntaryhmitys_code
kuntaryhmitys_name_fi
kuntaryhmitys_name_sv
kuntaryhmitys_name_en
maakunta_code
maakunta_name_fi
maakunta_name_sv
maakunta_name_en
seutukunta_code
seutukunta_name_fi
seutukunta_name_sv
seutukunta_name_en
year
suuralue_code
suuralue_name_fi
suuralue_name_sv
suuralue_name_en
nuts1_code
nuts1_name_fi
nuts1_name_sv
nuts1_name_en
nuts2_code
nuts2_name_fi
nuts2_name_sv
nuts2_name_en
nuts3_code
nuts3_name_fi
nuts3_name_sv
nuts3_name_en
vaalipiiri_code
vaalipiiri_name_fi
vaalipiiri_name_sv
vaalipiiri_name_en
hyvinvointialue_code
hyvinvointialue_name_fi
hyvinvointialue_name_sv
hyvinvointialue_name_en
yhteistyoalue_code
yhteistyoalue_name_fi
yhteistyoalue_name_sv
yhteistyoalue_name_en
tyollisyysalue_code
tyollisyysalue_name_fi
tyollisyysalue_name_sv
tyollisyysalue_name_en
evk_code
evk_name_fi
evk_name_sv
evk_name_en
municipality_code
kunta_name
name_fi
name_sv
kela_palvelualue_name_fi
kela_palvelualue_code
kela_palvelualue_name_sv
kela_palvelualue_name_en
kela_asumistukialue_name_fi
kela_asumistukialue_code
kela_asumistukialue_name_sv
kela_asumistukialue_name_en
https://data.stat.fi/api/classifications/v2/classifications
Downloads a specific collection of spatial data from the Maastotietokanta (Topographic Database) using the OGC API provided by the National Land Survey of Finland (NLS).
ogc_get_maastotietokanta( collection = "hautausmaa", crs = 3067, limit = NULL, max_pages = 100, bbox = NULL, api_key = getOption("geofi_mml_api_key") )ogc_get_maastotietokanta( collection = "hautausmaa", crs = 3067, limit = NULL, max_pages = 100, bbox = NULL, api_key = getOption("geofi_mml_api_key") )
collection |
Character. The name of the collection to download (e.g.,
|
crs |
Numeric or Character. The coordinate reference system (CRS)
for the output data, specified as an EPSG code. Supported values are
|
limit |
Numeric or NULL. The maximum number of features to retrieve in
a single API request. If |
max_pages |
Numeric. The maximum number of pages to fetch during pagination
when |
bbox |
Character or NULL. A bounding box to filter the data, specified as
a string in the format |
api_key |
Character. API key for authenticating with the Maastotietokanta
OGC API. Defaults to the value stored in
|
This function retrieves spatial data from the Maastotietokanta (Topographic Database) OGC API, provided by the National Land Survey of Finland (NLS). It acts as a wrapper around a lower-level API request function, adding user-friendly features like CRS transformation and spatial filtering.
Key features:
Supports pagination for large collections when limit=NULL.
Limits the number of pages fetched during pagination using max_pages.
Applies spatial filtering using a bounding box (bbox).
Transforms the output to the specified CRS (crs).
Validates inputs to prevent common errors.
To see the list of available collections, use
ogc_get_maastotietokanta_collections.
For very large collections (e.g., "suo"), the function may fetch data in
pages of 10,000 features each. If the number of pages exceeds max_pages,
a warning is issued, and only the features from the first max_pages pages
are returned. Increase max_pages to retrieve more features, but be aware
that this may significantly increase runtime.
An sf object containing the spatial features from the specified
collection, transformed to the requested crs.
Markus Kainu [email protected]
ogc_get_maastotietokanta_collections to list available collections.
https://www.maanmittauslaitos.fi/en/maps-and-spatial-data/datasets-and-interfaces/product-descriptions/topographic-database
for more information on the Maastotietokanta.
https://www.maanmittauslaitos.fi/en/rajapinnat/api-avaimen-ohje for
instructions on obtaining an API key.
## Not run: # Set your API key options(geofi_mml_api_key = "your_api_key_here") # Download the "hautausmaa" (cemeteries) collection in EPSG:3067 cemeteries <- ogc_get_maastotietokanta(collection = "hautausmaa") print(cemeteries) # Download the "suo" (bogs/marshes) collection with a higher page limit bogs <- ogc_get_maastotietokanta( collection = "suo", max_pages = 500 ) print(bogs) # Download with a bounding box (in EPSG:4326) and transform to EPSG:4326 cemeteries_bbox <- ogc_get_maastotietokanta( collection = "hautausmaa", bbox = "24.5,60.1,25.5,60.5", crs = 4326 ) print(cemeteries_bbox) ## End(Not run)## Not run: # Set your API key options(geofi_mml_api_key = "your_api_key_here") # Download the "hautausmaa" (cemeteries) collection in EPSG:3067 cemeteries <- ogc_get_maastotietokanta(collection = "hautausmaa") print(cemeteries) # Download the "suo" (bogs/marshes) collection with a higher page limit bogs <- ogc_get_maastotietokanta( collection = "suo", max_pages = 500 ) print(bogs) # Download with a bounding box (in EPSG:4326) and transform to EPSG:4326 cemeteries_bbox <- ogc_get_maastotietokanta( collection = "hautausmaa", bbox = "24.5,60.1,25.5,60.5", crs = 4326 ) print(cemeteries_bbox) ## End(Not run)
Retrieves a list of available collections from the Maastotietokanta (Topographic Database) OGC API, including their titles and descriptions.
ogc_get_maastotietokanta_collections(api_key = getOption("geofi_mml_api_key"))ogc_get_maastotietokanta_collections(api_key = getOption("geofi_mml_api_key"))
api_key |
Character. API key for authenticating with the Maastotietokanta
OGC API. Defaults to the value stored in |
This function queries the Maastotietokanta OGC API to retrieve metadata about
available collections of spatial data. The API is provided by the National Land
Survey of Finland (Maanmittauslaitos). The function requires a valid API key,
which can be provided directly or set via options(geofi_mml_api_key).
The function includes error handling:
It retries failed requests up to 3 times for transient network issues or server errors (HTTP 500–599) with exponential backoff.
It handles rate limits (HTTP 429) by respecting the Retry-After header.
It validates the API response to ensure the expected data is present.
A data frame with two columns:
id: The title of each collection.
description: A brief description of each collection.
https://www.maanmittauslaitos.fi/en/rajapinnat/api-avaimen-ohje for more information on the Maastotietokanta OGC API and how to obtain an API key.
## Not run: # Set your API key options(geofi_mml_api_key = "your_api_key_here") # Fetch the list of collections collections <- ogc_get_maastotietokanta_collections() print(collections) # Alternatively, provide the API key directly collections <- ogc_get_maastotietokanta_collections(api_key = "your_api_key_here") print(collections) ## End(Not run)## Not run: # Set your API key options(geofi_mml_api_key = "your_api_key_here") # Fetch the list of collections collections <- ogc_get_maastotietokanta_collections() print(collections) # Alternatively, provide the API key directly collections <- ogc_get_maastotietokanta_collections(api_key = "your_api_key_here") print(collections) ## End(Not run)
Queries the Geographic Names (Nimistö) OGC API to retrieve spatial data on place names provided by the National Land Survey of Finland (NLS).
ogc_get_nimisto( search_string = NULL, collection = "placenames", crs = 3067, limit = NULL, bbox = NULL, custom_params = NULL, api_key = getOption("geofi_mml_api_key") )ogc_get_nimisto( search_string = NULL, collection = "placenames", crs = 3067, limit = NULL, bbox = NULL, custom_params = NULL, api_key = getOption("geofi_mml_api_key") )
search_string |
Character or NULL. A search string to filter place names
(e.g., |
collection |
Character or NULL. The name of collection for places, place names and map names of the
Geographic Names Register provided by the National Land Survey of Finland where the search if performed from.
Supported values are |
crs |
Numeric or Character. The coordinate reference system (CRS)
for the output data, specified as an EPSG code. Supported values are
|
limit |
Numeric. The maximum number of features to retrieve in a single
API request. Defaults to 10. Set to |
bbox |
Character or NULL. A bounding box to filter the data, specified as
a string in the format |
custom_params |
Character or NULL. Additional query parameters to append
to the API URL, specified as a single string (e.g.,
|
api_key |
Character. API key for authenticating with the Geographic Names
OGC API. Defaults to the value stored in
|
This function retrieves spatial data on place names from the Geographic Names (Nimistö) OGC API, provided by the National Land Survey of Finland (NLS). It supports filtering by a search string (case-insensitive), spatial filtering using a bounding box, and limiting the number of returned features.
Key features:
Supports pagination for large datasets when limit=NULL.
Applies spatial filtering using a bounding box (bbox).
Transforms the output to the specified CRS (crs).
Validates inputs to prevent common errors.
An sf object containing the spatial features (place names) from
the Geographic Names dataset, transformed to the requested crs.
If no features are found, a warning is issued, and an empty sf object
may be returned.
Markus Kainu [email protected]
https://www.maanmittauslaitos.fi/nimiston-kyselypalvelu-ogc-api/tekninen-kuvaus for more information on the Geographic Names dataset. https://www.maanmittauslaitos.fi/en/rajapinnat/api-avaimen-ohje for instructions on obtaining an API key.
## Not run: # Set your API key options(geofi_mml_api_key = "your_api_key_here") # Search for place names containing "kainu" in EPSG:3067 places <- ogc_get_nimisto(search_string = "kainu") print(places) # Search with a bounding box (in EPSG:4326) and transform to EPSG:4326 places_bbox <- ogc_get_nimisto( search_string = "kainu", bbox = "24.5,60.1,25.5,60.5", crs = 4326 ) print(places_bbox) # Fetch all place names (no search filter) with a custom limit all_places <- ogc_get_nimisto( search_string = NULL, limit = 100 ) print(all_places) ## End(Not run)## Not run: # Set your API key options(geofi_mml_api_key = "your_api_key_here") # Search for place names containing "kainu" in EPSG:3067 places <- ogc_get_nimisto(search_string = "kainu") print(places) # Search with a bounding box (in EPSG:4326) and transform to EPSG:4326 places_bbox <- ogc_get_nimisto( search_string = "kainu", bbox = "24.5,60.1,25.5,60.5", crs = 4326 ) print(places_bbox) # Fetch all place names (no search filter) with a custom limit all_places <- ogc_get_nimisto( search_string = NULL, limit = 100 ) print(all_places) ## End(Not run)
Retrieves municipality or other administrative (multi)polygons from Statistics Finland's OGC API. Supports different years, scales, and tessellation types for Finnish administrative boundaries.
ogc_get_statfi_area( year = 2022, scale = 4500, tessellation = NULL, crs = 3067, limit = NULL, bbox = NULL )ogc_get_statfi_area( year = 2022, scale = 4500, tessellation = NULL, crs = 3067, limit = NULL, bbox = NULL )
year |
Integer. Year of the administrative borders. Options: 2020, 2021, 2022. Default: 2022. |
scale |
Integer. Map scale/resolution. Options: 1000 (1:1,000,000), 4500 (1:4,500,000). Default: 4500. |
tessellation |
Character or NULL. Type of administrative unit. Options: "avi", "ely", "hyvinvointialue", "kunta", "maakunta", "seutukunta", "suuralue", "tyossakayntialue", "vaalipiiri". If NULL, retrieves all units. Default: NULL. |
crs |
Integer. Coordinate Reference System (EPSG code). Options: 3067 (ETRS89 / TM35FIN), 4326 (WGS84). Default: 3067. |
limit |
Integer or NULL. Maximum number of features to retrieve. If NULL, retrieves all available features. Default: NULL. |
bbox |
Character or NULL. Bounding box for spatial filtering in format "xmin,ymin,xmax,ymax" (in the specified CRS). Default: NULL. |
An sf object containing the requested spatial data, or NULL if no data is retrieved.
Markus Kainu [email protected]
## Not run: # Get all municipalities for 2020 at 1:4,500,000 scale munis <- ogc_get_statfi_area(year = 2020, scale = 4500, tessellation = "kunta") # Get wellbeing areas for 2022 with a limit of 10 features wellbeing <- ogc_get_statfi_area(year = 2022, tessellation = "hyvinvointialue", limit = 10) # Get data within a bounding box bbox <- "200000,6600000,500000,6900000" data <- ogc_get_statfi_area(year = 2021, bbox = bbox, crs = 3067) ## End(Not run)## Not run: # Get all municipalities for 2020 at 1:4,500,000 scale munis <- ogc_get_statfi_area(year = 2020, scale = 4500, tessellation = "kunta") # Get wellbeing areas for 2022 with a limit of 10 features wellbeing <- ogc_get_statfi_area(year = 2022, tessellation = "hyvinvointialue", limit = 10) # Get data within a bounding box bbox <- "200000,6600000,500000,6900000" data <- ogc_get_statfi_area(year = 2021, bbox = bbox, crs = 3067) ## End(Not run)
Retrieves municipality or other administrative (multi)polygons with population data from Statistics Finland's OGC API. Supports different years and coordinate reference systems for Finnish administrative boundaries at a fixed scale of 1:4,500,000.
ogc_get_statfi_area_pop(year = 2023, crs = 3067, limit = NULL, bbox = NULL)ogc_get_statfi_area_pop(year = 2023, crs = 3067, limit = NULL, bbox = NULL)
year |
Integer. Year of the administrative borders and population data. Options: 2019, 2020, 2021. Default: 2021. |
crs |
Integer. Coordinate Reference System (EPSG code). Options: 3067 (ETRS89 / TM35FIN), 4326 (WGS84). Default: 3067. |
limit |
Integer or NULL. Maximum number of features to retrieve. If NULL, retrieves all available features. Default: NULL. |
bbox |
Character or NULL. Bounding box for spatial filtering in format "xmin,ymin,xmax,ymax" (in the specified CRS). Default: NULL. |
An sf object containing spatial data and population statistics, pivoted to wide format with variables as columns, or NULL if no data is retrieved.
Markus Kainu [email protected]
## Not run: # Get population data for 2020 pop_data <- ogc_get_statfi_area_pop(year = 2020, crs = 3067) # Get population data within a bounding box bbox <- "200000,6600000,500000,6900000" pop_data <- ogc_get_statfi_area_pop(year = 2021, bbox = bbox, crs = 3067) # Limit to 10 features pop_data <- ogc_get_statfi_area_pop(year = 2019, limit = 10, crs = 4326) ## End(Not run)## Not run: # Get population data for 2020 pop_data <- ogc_get_statfi_area_pop(year = 2020, crs = 3067) # Get population data within a bounding box bbox <- "200000,6600000,500000,6900000" pop_data <- ogc_get_statfi_area_pop(year = 2021, bbox = bbox, crs = 3067) # Limit to 10 features pop_data <- ogc_get_statfi_area_pop(year = 2019, limit = 10, crs = 4326) ## End(Not run)
Retrieves population data for Finnish statistical grid cells from Statistics Finland's OGC API. Supports different years and grid resolutions, with data in EPSG:3067 (ETRS89 / TM35FIN).
ogc_get_statfi_statistical_grid( year = 2021, resolution = 5000, limit = NULL, bbox = NULL )ogc_get_statfi_statistical_grid( year = 2021, resolution = 5000, limit = NULL, bbox = NULL )
year |
Integer. Year of the grid and population data. Options: 2019, 2020, 2021. Default: 2021. |
resolution |
Integer. Grid cell resolution in meters. Options: 1000 (1km), 5000 (5km). Default: 5000. |
limit |
Integer or NULL. Maximum number of features to retrieve. If NULL, retrieves all available features. Default: NULL. |
bbox |
Character or NULL. Bounding box for spatial filtering in format "xmin,ymin,xmax,ymax" (in EPSG:3067). Default: NULL. |
An sf object containing grid cell spatial data and population statistics, pivoted to wide format with variables as columns, or NULL if no data is retrieved.
Markus Kainu [email protected]
## Not run: # Get 5km grid population data for 2020 grid_data <- ogc_get_statfi_statistical_grid2(year = 2020, resolution = 5000) # Get 1km grid data within a bounding box bbox <- "200000,6600000,500000,6900000" grid_data <- ogc_get_statfi_statistical_grid2(year = 2021, resolution = 1000, bbox = bbox) # Limit to 10 features grid_data <- ogc_get_statfi_statistical_grid2(year = 2019, resolution = 5000, limit = 10) ## End(Not run)## Not run: # Get 5km grid population data for 2020 grid_data <- ogc_get_statfi_statistical_grid2(year = 2020, resolution = 5000) # Get 1km grid data within a bounding box bbox <- "200000,6600000,500000,6900000" grid_data <- ogc_get_statfi_statistical_grid2(year = 2021, resolution = 1000, bbox = bbox) # Limit to 10 features grid_data <- ogc_get_statfi_statistical_grid2(year = 2019, resolution = 5000, limit = 10) ## End(Not run)
This dataset contains population data at municipality level pulled from THL (Sotkanet) from 2000 to 2022
sotkadata_populationsotkadata_population
A data frame with 7107 rows and 3 variables:
municipality_code
primary.value
year
This dataset contains Swedish speaking population figures at municipality level pulled from THL (Sotkanet) from 2000 to 2022
sotkadata_swedish_speaking_popsotkadata_swedish_speaking_pop
A data frame with 5761 rows and 3 variables:
municipality_code
indicator.title.fi
primary.value
This dataset contains population for each zipcode in Finland. Data is downloaded from Statistics Finland
statfi_zipcode_populationstatfi_zipcode_population
A data frame with 3027 rows and 2 variables:
posti_alue
X2022
Statistics Finland WFS API response object's XML (GML) content is temporarily written on disk and then immediately read back in into a sf object.
to_sf(api_obj)to_sf(api_obj)
api_obj |
wfs api object |
sf object
For internal use, not exported.
Joona Lehtomäki [email protected]
Requests to various WFS API.
wfs_api(base_url = "https://geo.stat.fi/geoserver/wfs", queries)wfs_api(base_url = "https://geo.stat.fi/geoserver/wfs", queries)
base_url |
string Api base url |
queries |
list List of query parameters |
Make a request to the spesific WFS API. The base url is https://geo.stat.fi/geoserver/wfs to which other components defined by the arguments are appended.
This is a low-level function intended to be used by other higher level functions in the package.
Note that GET requests are used using httpcache meaning that requests
are cached. If you want clear cache, use httpcache::clearCache(). To turn
the cache off completely, use httpcache::cacheOff()
wfs_api (S3) object with the following attributes:
XML payload.
path provided to get the resonse.
the original response object.
Joona Lehtomäki [email protected]
wfs_api(base_url = "https://geo.stat.fi/geoserver/wfs", queries = append(list("service" = "WFS", "version" = "1.0.0"), list(request = "getFeature", layer = "tilastointialueet:kunta4500k_2017")))wfs_api(base_url = "https://geo.stat.fi/geoserver/wfs", queries = append(list("service" = "WFS", "version" = "1.0.0"), list(request = "getFeature", layer = "tilastointialueet:kunta4500k_2017")))