Skip to content

Commit 081d149

Browse files
author
Markus Kainu
committed
R/firstlib.R and vignettes modfies for package to be compatible with PROJ 9.6.0 changes
1 parent f7fa1d9 commit 081d149

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Type: Package
22
Package: geofi
33
Title: Access Finnish Geospatial Data
4-
Version: 1.0.18
5-
Date: 2025-02-11
4+
Version: 1.0.1801
5+
Date: 2025-04-12
66
Authors@R: c(
77
person("Markus", "Kainu", , "markus.kainu@kapsi.fi", role = c("aut", "cre"),
88
comment = c(ORCID = "0000-0003-1376-503X")),

R/firstlib.R

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11

22
.onAttach <- function(lib, pkg) {
3-
# packageStartupMessage("\ngeofi R package: tools for open GIS data for Finland.\nPart of rOpenGov <ropengov.org>.\n
4-
# **************\n
5-
# Please note that the content of variables 'hyvinvointialue_name_*' and 'hyvinvointialue_code' has changed in 1.0.6 release.\nNew content follows the classification by Statistics Finland.\n
6-
# **************")
3+
# packageStartupMessage("\ngeofi R package: tools for open GIS data for Finland.\nPart of rOpenGov <ropengov.org>.\n
4+
# **************\n
5+
# Please note that the content of variables 'hyvinvointialue_name_*' and 'hyvinvointialue_code' has changed in 1.0.6 release.\nNew content follows the classification by Statistics Finland.\n
6+
# **************")
7+
8+
# assing the modified data to global environment
9+
assign("municipality_central_localities", pkg_env$municipality_central_localities, envir = .GlobalEnv)
10+
packageStartupMessage("CRS in municipality_central_localties updated to match user PROJ-version")
711
}
812

913
# Create an empty environment to hold the WFS provider data
1014
wfs_providers <- new.env()
1115

16+
# Environment to store the modified data
17+
pkg_env <- new.env()
18+
# Set the data NULL in global environment
19+
municipality_central_localities <- NULL
20+
1221
#' @importFrom yaml read_yaml
1322
#' @importFrom purrr map2
23+
#' @importFrom sf st_transform
1424

1525
.onLoad <- function(lib, pkg) {
1626

@@ -19,4 +29,10 @@ wfs_providers <- new.env()
1929
package = "geofi"))
2030
# Map the providers and their data (URL, WFS version) to the environment
2131
purrr::map2(names(wfs_data), wfs_data, assign, envir = wfs_providers)
32+
33+
# Load the dataset into the package environment
34+
utils::data("municipality_central_localities", package = "geofi", envir = pkg_env)
35+
# Set CRS to 3067 that will vary whether user has PROJ < 9.6.0 or >= 9.6.0
36+
pkg_env$municipality_central_localities <- sf::st_transform(pkg_env$municipality_central_localities, 3067)
37+
2238
}

vignettes/geofi_making_maps.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Lets start with latest municipality division from `get_municipalities()` with is
5959
```{r municipality_map, fig.width = 5, eval = apiacc}
6060
library(geofi)
6161
polygon <- get_municipalities(year = 2021, scale = 4500)
62-
point <- geofi::municipality_central_localities
62+
point <- municipality_central_localities
6363
# municipality code into integer
6464
point$municipality_code <- as.integer(point$kuntatunnus)
6565
```

vignettes/geofi_spatial_analysis.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ The following operations derive from [Marko Kallio's](http://markokallio.fi/) co
205205

206206
### Polygon centroids
207207

208-
`geofi` contains data on municipality central locations (`geofi::municipality_central_localities`). Instead of those you may need the actual geographical centers ie. centroids of a polygon that can be computed using `st_centroid` and plotted with ggplot.
208+
`geofi` contains data on municipality central locations (`municipality_central_localities`). Instead of those you may need the actual geographical centers ie. centroids of a polygon that can be computed using `st_centroid` and plotted with ggplot.
209209

210210
```{r centroids, fig.width=5, eval = apiacc_pkginst}
211211
muni_centroids <- st_centroid(muni)
@@ -300,7 +300,7 @@ You can calculate distance matrices using [`st_distance()`](https://r-spatial.gi
300300
First we need to subset the data and replace original municipality name column (`teksti`) with *better* from latest municipality key.
301301

302302
```{r kunnat, eval = apiacc_pkginst}
303-
kunta <- geofi::municipality_central_localities %>%
303+
kunta <- municipality_central_localities %>%
304304
select(teksti,kuntatunnus) %>%
305305
mutate(kuntatunnus = as.integer(kuntatunnus)) %>%
306306
select(-teksti) %>%

0 commit comments

Comments
 (0)