From e253e4a5146f90bf51cefd6fa4f03b07f20567e7 Mon Sep 17 00:00:00 2001 From: stienheremans Date: Wed, 11 Dec 2024 11:19:55 +0100 Subject: [PATCH] Try to het orthophotos from WMTS --- source/Drone_images.Rmd | 2 +- source/Orthophoto_processing.Rmd | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 source/Orthophoto_processing.Rmd diff --git a/source/Drone_images.Rmd b/source/Drone_images.Rmd index d3182ea..09d796c 100644 --- a/source/Drone_images.Rmd +++ b/source/Drone_images.Rmd @@ -110,7 +110,7 @@ grid.arrange( # Step 2: Visualize actual drone images -```{r} +```{r visualize drone images} ``` diff --git a/source/Orthophoto_processing.Rmd b/source/Orthophoto_processing.Rmd new file mode 100644 index 0000000..954483e --- /dev/null +++ b/source/Orthophoto_processing.Rmd @@ -0,0 +1,62 @@ +--- +title: "Orthophoto analysis" +output: html_notebook +--- + +```{r get orthophotos through WMTS} +library(xml2) + +# Your WMTS GetCapabilities URL +wmts_url <- "https://geo.api.vlaanderen.be/omz/wmts?request=getcapabilities&service=wmts&version=1.0.0" + +# Fetch the WMTS capabilities XML +wmts_capabilities <- read_xml(wmts_url) + +# Parse information from the XML +subnodes <- xml_children(wmts_capabilities) + +# get into the Contents part of the XML +contents_node <- subnodes[[4]] + +# Get all nodes under +layers <- xml_children(contents_node) + +# Loop through each and extract information +layers_info <- lapply(layers, function(layer_node) { + title <- xml_text(xml_find_first(layer_node, ".//ows:Title")) + identifier <- xml_text(xml_find_first(layer_node, ".//ows:Identifier")) + + # Bounding box + bbox_lower <- xml_text(xml_find_first(layer_node, ".//ows:LowerCorner")) + bbox_upper <- xml_text(xml_find_first(layer_node, ".//ows:UpperCorner")) + + # Format + format <- xml_text(xml_find_first(layer_node, ".//*[local-name()='Format']")) + + # Tile matrix sets + tile_matrix_sets <- paste(xml_text(xml_find_all(layer_node, ".//*[local-name()='TileMatrixSet']")), collapse = ", ") + + # Return as a list + data.frame( + Title = title, + Identifier = identifier, + BoundingBoxLower = bbox_lower, + BoundingBoxUpper = bbox_upper, + Format = format, + TileMatrixSets = tile_matrix_sets, + stringsAsFactors = FALSE + ) +}) + +# Combine all layer data frames into one +layers_df <- do.call(rbind, layers_info) + +# Print the resulting data frame +print(layers_df) + +``` +```{r get forest polygons from WMTS} + + +``` +