Open mdsumner opened 1 year ago
#xml vrt library(xml2) x <- read_xml("https://pgc-opendata-dems.s3.us-west-2.amazonaws.com/rema/mosaics/v2.0/2m_dem_tiles.vrt") findem <- c("SourceFilename", "SourceProperties", "SrcRect", "DstRect") gt <- as.numeric(unlist(strsplit(as.character(xml_contents(xml_find_first(x, ".//GeoTransform"))), ","))) crs <- as.character(xml_contents(xml_find_first(x, ".//SRS"))) ## we need VRT datatype and size dm <- as.integer(xml_attrs(x)) bands <- as.character(xml_attrs(xml_find_first(x, ".//VRTRasterBand")) ) srcprops <- do.call(cbind, lapply(findem, \(.x) do.call(rbind, xml_attrs(xml_find_all(x, sprintf(".//%s", .x))))))