You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vignettes/geofi_statfi_ogc.Rmd
+46-31Lines changed: 46 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
---
2
-
title: "Accessing Spatial and Population Data from Statistics Finland OGC api"
2
+
title: "Accessing Data from Statistics Finland OGC api"
3
3
author: "Markus Kainu"
4
4
date: "`r Sys.Date()`"
5
5
output: rmarkdown::html_vignette
6
6
vignette: >
7
-
%\VignetteIndexEntry{Accessing Spatial and Population Data from Statistics Finland OGC api}
7
+
%\VignetteIndexEntry{Accessing Data from Statistics Finland OGC api}
8
8
%\VignetteEngine{knitr::rmarkdown}
9
9
%\VignetteEncoding{UTF-8}
10
10
---
@@ -31,16 +31,15 @@ The `geofi` package provides tools to access spatial data from **Statistics Finl
31
31
* Fetch population data linked to administrative units.
32
32
* Access population data for statistical grid cells.
33
33
34
-
Unlike some other spatial data APIs, *no API key is required* to access Statistics Finland's OGC API, making it straightforward to get started. The package handles pagination, spatial filtering, and coordinate reference system (CRS) transformations, delivering data as `sf` objects compatible with the `sf` package for spatial analysis and visualization.
34
+
The package handles pagination, spatial filtering, and coordinate reference system (CRS) transformations, delivering data as `sf` objects compatible with the `sf` package for spatial analysis and visualization.
35
35
36
36
## Package Overview
37
37
38
38
The `geofi` package includes the following key functions for accessing Statistics Finland data:
39
39
40
-
*`ogc_get_statfi_area()`: Retrieves administrative area polygons (e.g., municipalities, wellbeing areas) for specified years, scales, and tessellation types.
40
+
*`ogc_get_statfi_area()`: Retrieves administrative area polygons (e.g., municipalities, wellbeing areas) for specified yearsand scales.
41
41
*`ogc_get_statfi_area_pop()`: Fetches administrative area polygons with associated population data, pivoted into a wide format.
42
42
*`ogc_get_statfi_statistical_grid()`: Retrieves population data for statistical grid cells at different resolutions (1km or 5km).
43
-
*`fetch_ogc_api_statfi()`: An internal function that handles low-level API requests and pagination (not typically called directly by users).
44
43
45
44
All functions return spatial data as `sf` objects, making it easy to integrate with spatial analysis workflows in R.
46
45
@@ -60,38 +59,37 @@ The `ogc_get_statfi_area()` function retrieves polygons for Finnish administrati
60
59
Fetch all municipalities for 2022 at the 1:4,500,000 scale:
Visualize population density (assuming a variable like `population_total` exists):
127
+
By default, function returns the at all regional breakdown available, and it is users task to filter out the regional breakdown of interest. At the moment, that can be down using regular expressions on the prefix of variable `areaStatisticalUnit_inspireId_localId`. Following prefixes are available `"avi", "ely", "kunta", "maakunta", "seutukunta", "suuralue"`
128
+
129
+
130
+
Visualize the share of female population at municpality (`kunta`) level.
131
131
132
132
```{r}
133
-
ggplot(pop_data) +
134
-
geom_sf(aes(fill = population_total)) +
135
-
scale_fill_viridis_c(option = "plasma") +
136
-
theme_minimal() +
137
-
labs(title = "Population by Administrative Area (2021)", fill = "Population")
labs(title = "Population by 1km Grid Cells (2021)", fill = "Population")
203
+
```
204
+
190
205
## Advanced Features
191
206
192
207
### Pagination
@@ -212,7 +227,7 @@ Note that `ogc_get_statfi_statistical_grid()` is fixed to EPSG:3067, as per the
212
227
213
228
### Bounding Box Filtering
214
229
215
-
The `bbox` parameter allows spatial filtering to focus on specific regions. Ensure coordinates match the specified `crs` (e.g., EPSG:3067 for grid data). Example format: "`200000`,`6600000`,`500000`,`6900000`".
230
+
The `bbox` parameter allows spatial filtering to focus on specific regions. Bounding box coordinates in EPSG:4326 will work with both crs EPSG:4326 and EPSG:3067. Bounding box in EPSG:3067 requires crs to be also set to EPSG:3067 with the function argument. Example format: `"18.797607,59.573288,30.476074,61.695082"`.
0 commit comments