Closed NewGraphEnvironment closed 1 year ago
This is what I got so far. I've imported the gpx files successfully but I can't run the function that adds lon and lat to the track points. I get an error message saying "Error in drake::readd(track_points_mw) : cannot find drake cache."
# read in Mateo gpx file
gpx <- 'C:/Users/matwi/OneDrive/Projects/repo/fish_passage_peace_2022_reporting/data/gps/parsnip_2022_field_mw.GPX'
track_points_mw = read_sf(gpx, layer = "track_points")
# read in Al gpx file
gpx <- 'C:/Users/matwi/OneDrive/Projects/repo/fish_passage_peace_2022_reporting/data/gps/parsnip_2022_field_al.GPX'
track_points_ai = read_sf(gpx, layer = "track_points")
##add lon, lat to our track points
track_points2 <- dplyr::bind_cols(
drake::readd(track_points_mw),
drake::readd(track_points_mw) %>%
st_coordinates() %>%
as_tibble() %>%
setNames(c("lon_gps_linked","lat_gps_linked"))
) %>%
tibble::rownames_to_column() %>%
mutate(time = lubridate::as_datetime(time, tz="America/Vancouver"))
had written something about drake
earlier but never ended up sending it. dang. We don't use drake
anymore. that function is just calling that object. you can use the object you read in with sf::read_sf
instead. You don't need to read in my track points because my photos are georeferenced. After joining iphone metadata to your metadata with the coordinates added it will be a case_when
on a condition that there is no populated value for lat long already that will tell the script to sub in the new coordinates to the iphone columns for your photos only
Closed via commit here
Should be able to use
sf
to read inparsnip_2022_field_mw.GPX
and use just the camera owner track_points (not mine) to do the match to camera photo metadata by nearest time. Really we need to just join two data frames 1. photo_metadata 2. track_points by the closest time (using indexes generated by iterating through the difference in times between each photo CreateDate and all the track_points.Once the match is done we rename or mutate some columns so photo metadata can align with iphone columns.
Pretty sure the heavy lifting for what needs to happen is captured in portion of this script here. Obviously, the names of photo metadata columns below are likely different. You can see the gpx layers through
sf::st_layers
: