Skip to content

Commit

Permalink
Try to het orthophotos from WMTS
Browse files Browse the repository at this point in the history
  • Loading branch information
stienheremans committed Dec 11, 2024
1 parent b89e728 commit e253e4a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/Drone_images.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ grid.arrange(


# Step 2: Visualize actual drone images
```{r}
```{r visualize drone images}

Check warning on line 114 in source/Drone_images.Rmd

View workflow job for this annotation

GitHub Actions / check project with checklist

file=source/Drone_images.Rmd,line=114,col=1,[trailing_blank_lines_linter] Trailing blank lines are superfluous.
```

62 changes: 62 additions & 0 deletions source/Orthophoto_processing.Rmd
Original file line number Diff line number Diff line change
@@ -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"

Check warning on line 10 in source/Orthophoto_processing.Rmd

View workflow job for this annotation

GitHub Actions / check project with checklist

file=source/Orthophoto_processing.Rmd,line=10,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 103 characters.
# 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 <Layer> nodes under <Contents>
layers <- xml_children(contents_node)
# Loop through each <Layer> 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"))

Check warning on line 28 in source/Orthophoto_processing.Rmd

View workflow job for this annotation

GitHub Actions / check project with checklist

file=source/Orthophoto_processing.Rmd,line=28,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.
# Bounding box
bbox_lower <- xml_text(xml_find_first(layer_node, ".//ows:LowerCorner"))
bbox_upper <- xml_text(xml_find_first(layer_node, ".//ows:UpperCorner"))

Check warning on line 32 in source/Orthophoto_processing.Rmd

View workflow job for this annotation

GitHub Actions / check project with checklist

file=source/Orthophoto_processing.Rmd,line=32,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.
# 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}
```

0 comments on commit e253e4a

Please sign in to comment.