feed <- try(xml2::as_list(xml2::read_xml("https://apli.bizkaia.eus/apps/Danok/INSPIRE/buildings.xml",
options = "NOCDATA",
encoding = "UTF-8"
)), silent = TRUE)
feed <- feed$feed
feed <- feed[names(feed) == "entry"]
tbl_all <- lapply(feed, function(x) {
title <- unlist(x[["title"]])
url <- unlist(x[["id"]])
date <- unlist(x[["updated"]])
tbl <- tibble::tibble(
title = trimws(title), url = trimws(url),
date = date
)
return(tbl)
})
tbl_all <- dplyr::bind_rows(tbl_all)
# Prueba con uno
url <- tbl_all$url[20]
name <- basename(url)
folder <- tools::file_path_sans_ext(name)
if (!dir.exists(folder)) dir.create(folder)
download.file(url, file.path(folder, name))
unzip(file.path(folder, name), exdir = folder, junkpaths = TRUE)
thefile <- list.files(folder, pattern = ".gml", full.names = TRUE)
library(tidyverse)
sf::st_read(thefile) %>%
ggplot() +
geom_sf()
#> Reading layer `Building' from data source
#> `C:\Users\diego\Documents\R\Projects\myosmwork\ES.BFA.BU.020\ES.BFA.BU.gml'
#> using driver `GML'
#> Simple feature collection with 13772 features and 29 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -2.985693 ymin: 43.21846 xmax: -2.881148 ymax: 43.29002
#> Geodetic CRS: ETRS89ATOM Bizkaia
Ejemplo
Lectura basado en CatastRo:::catr_read_atom: