Open muuankarski opened 5 years ago
Created a new branch and wrote simple function & tutorial example here: https://github.com/rOpenGov/geofi/commit/b67fcd329d56147b5f6b047506d6b949028a7330
stale branch feature-vrk-building
removed
content below:
#' @title Get geospatial data with all buildings and electoral districts from Väestörekisterikeskus
#' @description preprocessed geospatial data sf-objects
#' @author Markus Kainu <markus.kainu@kela.fi>
#' @return sf-object
#' @export
#' @examples
#' \dontrun{
#' f <- get_buildings()
#' plot(f)
#' }
#'
#' @rdname get_buildings
#' @export
get_buildings <- function(){
library(dplyr)
library(sp)
library(sf)
tmpfile <- tempfile()
tmpdir <- tempdir()
download.file("https://www.avoindata.fi/data/dataset/cf9208dc-63a9-44a2-9312-bbd2c3952596/resource/ae13f168-e835-4412-8661-355ea6c4c468/download/suomi_osoitteet_2019-08-15.zip",
destfile = tmpfile)
unzip(zipfile = tmpfile,
exdir = tmpdir)
opt <- read.csv(glue::glue("{tmpdir}/suomi_osoitteet_2019-08-15.OPT"), fileEncoding = "latin1",
sep = ";",
# nrows = 50000,
stringsAsFactors = FALSE,
header = FALSE)
names(opt) <- c("rakennustu","sijaintiku",
"sijaintima","rakennusty",
"CoordY","CoordX",
"osoitenume", "katunimi_f",
"katunimi_s", "katunumero",
"postinumer", "vaalipiirikoodi",
"vaalipiirinimi","tyhja",
"idx", "date")
sp.data <- SpatialPointsDataFrame(opt[, c("CoordX", "CoordY")],
opt,
proj4string = CRS("+init=epsg:3067"))
# Project the spatial data to lat/lon
# sp.data <- spTransform(sp.data, CRS("+proj=longlat +datum=WGS84"))
shape <- st_as_sf(sp.data)
# st_coordinates(shape)
# shape %>% select(rakennustu) %>% plot()
return(shape)
}
Väestörekisterikeskus publishes annually data containing all buildings in Finland. Data is zipped delimited file with
.OPT
-extension and has 3,6 million rows. It can be read and processed in R (slowly) with following code:Any ideas how to incorporate this with
geofi
. It is useful for instance when geocoding sensitive addresses.However, this would require a storage as the data should be preprocessed. Do you think this as a suitable data for
geofi
and should we create a data repo such asgeofi_data
?