## Setup
knitr::opts_chunk$set(echo = TRUE)

## Import database of known sensors
cameras_fn <- system.file("cameras/cameras.csv", package="uavimg")
sensors_df <- read.csv(cameras_fn, stringsAsFactors = FALSE)

## Search for this sensor
camera_make <- params$pts@data[1, "make"]
camera_model <- params$pts@data[1, "model"]
camera_filetype <- params$pts@data[1, "filetype"]

sensor_this_df <- dplyr::filter(sensors_df, model==camera_model & filetype==camera_filetype)

## Get the composite camera name from the sensor database
if (nrow(sensor_this_df)==0) {
  camera_name <- "unknown"
} else {
  camera_name <- sensor_this_df[1, "camera_name"]
}

## Get the image dimensions
img_pixels <- paste0(params$pts@data[1, "img_width"], " x ", params$pts@data[1, "img_height"])

## Get the start and end time formmated
dt_posix <- as.POSIXct(params$pts@data$date_time, format="%Y:%m:%d %H:%M:%S")
dt_range <- format(range(dt_posix), "%b %d %Y, %I:%M:%S %p")

r basename(params$img_dir)

__Directory__:`r gsub("\\\\","/",params$img_dir)`
__Num images__:`r nrow(params$pts)`
__Area__:`r round(msq2acres(params$area_m2),2)` acres
__Start__:`r dt_range[1]`
__End__:`r dt_range[2]`
__Camera__:`r camera_name`
__Image size__:`r img_pixels`

Maps {.tabset}

Centers

## Initiate a new leaflet object
m <- leaflet(width="800px", height="600px")

## Add tiles properties
tiles_esri_url = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
tiles_esri_attr = "Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community"

m <- m %>% addTiles(tiles_esri_url, group="Satellite", attribution=tiles_esri_attr) %>% addTiles(group="Open Street Map") %>% addLayersControl(baseGroups = c("Satellite", "Open Street Map"), options = layersControlOptions(collapsed = FALSE))

## Set the bounding box
lng_rng <- range(params$pts@data$gps_long)
lat_rng <- range(params$pts@data$gps_lat)
m_pts <- m %>% fitBounds(lng_rng[1], lat_rng[1], lng_rng[2], lat_rng[2])

## Create the balloons
pts_dt <- as.POSIXct(params$pts@data$date_time, format="%Y:%m:%d %H:%M:%S")
balloons_html <- paste0("<p><b>", params$pts@data$file_name, "</b><br/>", format(pts_dt, "%b %d, %Y"), "<br/>", format(pts_dt, "%I:%M:%S %p"), "</p>")

#fillColor <- "yellow"
#fillColor <- rainbow(nrow(params$pts@data), end=5/6)

## Add circle markers
m_pts <- m_pts %>% addCircleMarkers(lng=params$pts@data$gps_long, lat=params$pts@data$gps_lat, radius=3, stroke=FALSE, fillColor=params$col, fillOpacity=1, popup=balloons_html)

## Display HTML Widget
m_pts

Footprints

if (is.null(params$fp)) {
  htmltools::p("Image footprints not computed! (perhaps because yaw data was not saved in the EXIF)")
} else {  
  ## Reproject footprints to lat-long (required by leaflet)
  crsLatLong <- CRS("+proj=longlat +datum=WGS84")
  fpLL <- spTransform(geometry(params$fp), crsLatLong)

  ## Set the bounding box
  fpBBox <- bbox(fpLL)
  m_fp <- m %>% fitBounds(fpBBox[1,1], fpBBox[2,1], fpBBox[1,2], fpBBox[2,2])

  #outline_color <- c("yellow", "LightPink")[1]
  #outline_color <- rainbow(length(fpLL), end=5/6)

  ## Add polygons
  m_fp <- m_fp %>% addPolygons(data=fpLL, fill=FALSE, stroke=TRUE, color=params$col, weight=2, dashArray="1,2")

  ## Display HTML Widget
  m_fp
}

EXIF Data Analysis

hist(cm2in(params$pts@data$gsd), col="grey50", breaks=20, main="Ground Sampling Distance", xlab="estimated GSD (inches)", ylab="freq")
if ("alt_agl" %in% names(params$pts@data)) {
  hist(m2ft(params$pts@data$alt_agl), col="grey50", breaks=20, main=" Altitude", xlab="recorded altitude above launch (ft)", ylab="freq")
}
if (!is.null(params$fp)) {
  hist(params$fp@data$fwd_ovrlap, col="grey50", breaks=20, main="Forward Overlap", xlab="estimated overlap (%)", ylab="freq")
}


Created with Drone Image Utils for R



UCANR-IGIS/uavimg documentation built on July 13, 2020, 9:35 p.m.