Closed meztez closed 1 year ago
Negative elevation, most likely bad record has it is pretty hard to fly underground.
read_GPX <- function(file) { layers_data <- sf::st_layers(file) non_empty <- layers_data[["name"]][which(layers_data[["features"]] > 0)] |> setNames(nm = _) lapply(non_empty, sf::st_read, dsn = file, quiet = TRUE) |> `class<-`("flightGPX") } dem_extract <- function(pts, method = c("simple", "bilinear"), ...) { method <- match.arg(method) dem <- sf::st_bbox(pts) |> # simplify geometry to retrieve required dem sf::st_as_sfc() |> # recast to sfc to allow buffer around sf::st_buffer(units::set_units(50, m), nQuadSegs = 1) |> # add a margin to allow bilinear sf::st_bbox() |> # recompute bounding box before querying dem bcmaps::cded(aoi = _, ...) |> # obtain tiles terra::rast() # cast as raster terra::extract( x = dem, y = sf::st_transform(pts, crs = sf::st_crs(dem)) |> terra::vect(), method = method, ID = FALSE )[,1] } #TODO: Investigate # GPS Elevation not reliable unless you can fly below mountains? f <- read_GPX("./data-raw/Heli data/NEH/2021/20220317-145549-0032969-139533.gpx") pts <- f$track_points[3673:3713,] |> sf::st_geometry() gps_ele <- f$track_points[3673:3713,]$ele real_ele <- dem_extract(pts, method = "bilinear", check_tiles = FALSE) leaflet::leaflet(pts) |> leaflet::addProviderTiles("OpenTopoMap") |> leaflet::addMarkers( label = sprintf( "<p>GPS Elevation: %s<br>DEM Elevation: %s</p>", gps_ele, round(real_ele, 2) ) |> lapply(FUN = htmltools::HTML) )
GPS : -90.2 DEM : 1691
Solution: Smooth, Moving Average?
For now, we will use a simple pmax(0, agl) as was done in the python code.
pmax(0, agl)
Approved, see meetings note
Negative elevation, most likely bad record has it is pretty hard to fly underground.
GPS : -90.2 DEM : 1691
Solution: Smooth, Moving Average?