| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #' Tuumandmete WFS kihtide lugemine
- #'
- #' See on Eesti topograafia andmekogu tuumandmete kaardikihte WFS allalaadimisteenuse kaardikihtide lugemine. \url{https://gsavalik.envir.ee/geoserver/etak/wfs?service=WFS&request=GetCapabilities}
- #'
- #' @return matrix
- #' @importFrom magrittr %>%
- #' @noRd
- #' @examples
- #' \dontrun{
- #'
- #' loe_tuumandmete_wfs_kihid()
- #' }
- #'
- loe_tuumandmete_wfs_kihid <- function() {
- # Andmeallikas
- url <-
- "https://teeregister-api.mnt.ee/teenus/wfs?request=GetCapabilities&service=WFS"
- data <- xml2::read_xml(url) %>% xml2::xml_contents()
- result <- data[[4]] %>% xml2::xml_children()
- list <- lapply(1:length(result), function(i) {
- layer <-
- (result[[i]] %>% xml2::xml_children() %>% xml2::xml_text())[1]
- title <-
- (result[[i]] %>% xml2::xml_children() %>% xml2::xml_text())[2]
- abstract <-
- gsub("\n",
- "",
- (result[[i]] %>% xml2::xml_children() %>% xml2::xml_text())[3])
- defaultCRS <-
- gsub("urn:ogc:def:crs:",
- "",
- (result[[i]] %>% xml2::xml_children() %>% xml2::xml_text())[4])
- bbox <-
- (result[[i]] %>% xml2::xml_children() %>% xml2::xml_text())[8]
- metadataURL <-
- (result[[i]] %>% xml2::xml_children())[9] %>% xml2::xml_attr("href")
- c(
- "layer" = layer,
- "title" = title,
- "abstract" = abstract,
- "defaultCRS" = defaultCRS,
- "bbox" = bbox,
- "metadataURL" = metadataURL
- )
- })
- do.call("rbind", list)
- }
|