Skip to content

Commit

Permalink
+ pxweb removed from suggested packages list.
Browse files Browse the repository at this point in the history
+ WFS api url fixed in Description
  • Loading branch information
Markus Kainu committed Jan 24, 2024
1 parent 870b44b commit 0528f89
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 29 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: geofi
Title: Access Finnish Geospatial Data
Version: 1.0.12
Version: 1.0.13
Date: 2024-01-24
Authors@R: c(
person("Markus", "Kainu", , "markus.kainu@kapsi.fi", role = c("aut", "cre"),
Expand All @@ -16,7 +16,7 @@ Authors@R: c(
person("Leo", "Lahti", , "leo.lahti@iki.fi", role = "aut",
comment = c(ORCID = "0000-0001-5537-637X"))
)
Description: Designed to simplify geospatial data access from the Statistics Finland Web Feature Service API <http://geo.stat.fi/geoserver/wfs>, 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.
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.
License: BSD_2_clause + file LICENSE
URL: https://github.com/rOpenGov/geofi
BugReports: https://github.com/rOpenGov/geofi/issues
Expand Down Expand Up @@ -44,7 +44,6 @@ Suggests:
knitr,
leaflet,
patchwork,
pxweb,
readr,
rmarkdown,
sotkanet,
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# geofi 1.0.12

+ Vignettes made more robust agains missing suggested dependencies, pxweb in this case
+ pxweb removed from suggested packages list.
+ WFS api url fixed in Description

# geofi 1.0.11

Expand Down
3 changes: 2 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

## Submission note

* Vignettes made more robust against missing Suggest packages
+ pxweb removed from suggested packages list.
+ WFS api url fixed in Description

## R CMD check results

Expand Down
30 changes: 6 additions & 24 deletions vignettes/geofi_joining_attribute_data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ check_namespaces <- function(pkgs){
return(all(unlist(sapply(pkgs, requireNamespace,quietly = TRUE))))
}
apiacc <- geofi::check_api_access()
pkginst <- check_namespaces(c("sotkanet","dplyr","tidyr","janitor","ggplot2","pxweb"))
pkginst <- check_namespaces(c("sotkanet","dplyr","tidyr","janitor","ggplot2"))
apiacc_pkginst <- all(apiacc,pkginst)
```

Expand Down Expand Up @@ -92,41 +92,23 @@ map_data %>%

## Zipcode level

You can download data from [Paavo (Open data by postal code area)](https://pxdata.stat.fi/PXWeb/pxweb/en/Postinumeroalueittainen_avoin_tieto/) using `pxweb`-package in a similar manner as in the first example.
You can download data from [Paavo (Open data by postal code area)](https://pxdata.stat.fi/PXWeb/pxweb/en/Postinumeroalueittainen_avoin_tieto/) using [`pxweb`](https://ropengov.github.io/pxweb/)-package. In this example we will download preformatted population data in `csv` format directly from Statistics Finland and process it to match with spatial zipcode data.

```{r zipcode_with_statistics_finland, eval = apiacc_pkginst}
library(pxweb)
# lets get all zipcodes and all variables
pxweb_query_list <-
list("Postinumeroalue"=c("*"),
"Tiedot"=c("he_vakiy"),
"Vuosi"=c("2021"))
px_raw <-
pxweb_get(url = "https://statfin.stat.fi/PXWeb/api/v1/en/Postinumeroalueittainen_avoin_tieto/uusin/paavo_pxt_12ey.px",
query = pxweb_query_list)
px_data <- as_tibble(
as.data.frame(px_raw,
column.name.type = "text",
variable.value.type = "text")
) %>% setNames(janitor::make_clean_names(names(.)))
px_data %>%
filter(postal_code_area != "Finland")
px_data <- read.csv("https://pxdata.stat.fi:443/PxWeb/sq/43d3d0aa-636e-4a4b-bbe1-decae45fc2b4",
header = TRUE, sep = ";", fileEncoding = "Latin1")
px_data$posti_alue <- sub(" .+$", "", px_data$Postinumeroalue)
```

Before we can join the data, we must extract the numerical postal code from `postal_code_area`-variable.

```{r get_zipcodes, eval = apiacc_pkginst}
px_data$posti_alue <- sub(" .+$", "", px_data$postal_code_area)
# Lets join with spatial data and plot the area of each zipcode
zipcodes19 <- get_zipcodes(year = 2019)
zipcodes_map <- left_join(zipcodes19,
px_data)
ggplot(zipcodes_map) +
geom_sf(aes(fill = inhabitants_total_he),
geom_sf(aes(fill = X2021),
color = alpha("white", 1/3)) +
labs(title = "Total number of inhabitants, 2021",
fill = NULL)
Expand Down

0 comments on commit 0528f89

Please sign in to comment.