Drone Image Utilities for R
Overview

Andy Lyons

May 2021


https://ucanr-igis.github.io/uasimg

Motivation

Drone Mapping Data - Where it Starts


Volume and Variety - Double Trouble

raw images
flight log
study area outline
GCP coordinates
telemetry files
ground samples
other photos
video files basemap layers

I know it’s here somewhere.

Yeah I remember hearing someone flew that site.

Did you ask Brandon?
I found the images, but I can’t reproduce the stitching. It looks funny.

Maybe the overlap was too low?
We have to report how many acres we’ve flown with each type of camera for the USDA report.

Whatdyathink?

How do we get our drone data to be FAIR compliant?

uasimg Overview

R package with functions to help you:

Data Catalog Tour

Origins


https://is.gd/uas_data_aag2019


Why R?

Step 1. Extract Image EXIF Data

ptpinole_info = uas_info("d:/uas/ptpinole/west/march2020/dcim")

This will:

  1. extract the image coordinates
  2. read the sensor type, location, yaw, focal length, etc.
  3. compute image footprints
  4. create an minimum convex polygon (MCP) for the entire flight
  5. read flight metadata
  6. cache all the results
  7. return a “Flight Info” object

You can process multiple directories at once

A “Flight Info” object by itself is not very useful!

Step 2. Create / Edit Flight Metadata

Image metadata vs Flight Metadata

Image metadata

Flight metadata


Entering Flight Metadata

Recommended way to record flight metadata - Notepad!

uas_flds_oem()
##  [1] "name_short"  "name_long"   "description" "proj"        "loc"        
##  [6] "pilot"       "contact"     "uav"         "data_url"    "tags"       
## [11] "notes"


Flight Metadata Helper Function

You don’t have to start from scratch!

uas_metadata_make(ptpinole_info)


Re-run uas_info() after you edit flight metadata!

Step 3. Export flight geometry as GIS files

If desired, you can export the flight geometry:

uas_exp_kml(ptpinole_infox)
uas_exp_shp(ptpinole_info)

Move Your Data into Standard Directory Trees

You can move your data by hand or with a function:

uas_move(ptpinole_info)

Function options:

{proj}/{loc}/{subloc}/imgs/{flt_date}/{flt_start}-{flt_end}_{camera_abbrev}
{proj}/{loc}/{subloc}/gis
{proj}/{loc}/{subloc}/p4d
{proj}/{loc}/{subloc}/documents

Create a Flight Summary Report

Create HTML flight summary for one or more Flight Info object(s):

uas_report(ptpinole_info)

Report options:

Group Flight Summary Reports into a Table of Contents

Feed a list of Flight Summary HTML files.

uas_toc(c("d:/uas/ptpinole/west/march2020/dcim/map/ptpinole_mar2020.html",
          "d:/uas/ptpinole/west/jul2020/dcim/map/ptpinole_jul2020.html",
          "d:/uas/ptpinole/west/oct2020/dcim/map/ptpinole_oct2020.html"))

It will extract flight metadata fields from the HTML file for the table-of-contents.

Function options:

Sample code that does everything

library(uasimg)

## Set the working directory to the parent directory of the image folders:
setwd("D:\\Pix4D\\HREC\\Watershed1\\Data\\2017-01-16_X5")

hrec_dirs <- c("Flight01_1514_1526_400ft", "Flight02_1532_1540_400ft")
file.exists(hrec_dirs)

## Make metadata text files
# uas_metadata_make(hrec_dirs, make_new = TRUE, overwrite = FALSE, open = TRUE, use_system_editor = TRUE)

## Extract flight metadata
hrec_info <- uas_info(hrec_dirs, fp = TRUE)

## Create reports
hrec_rpt <- uas_report(hrec_info, thumbnails = FALSE,
                       attachments = c("mcp_kml", "ctr_kml"),
                       footer_html = "D:\\GitHub\\uasimg\\headers_footers\\footer_igis.html",
                       png_map = TRUE, group_img = FALSE, show_local_dir = TRUE,
                       overwrite_html = TRUE, open_report = TRUE)

## Create a TOC
hrec_toc <- uas_toc(hrec_rpt,
                    toc_title = "HREC Watershed2, January 2017",
                    output_dir = ".",
                    fltmap_base = list(list(kml_fn = "D:\\Pix4D\\HREC\\Baselayers\\hopland.kml",
                                            color = "red",
                                            weight = 2)),
                    fltmap_kml = TRUE,
                    footer_html = "D:\\GitHub\\uasimg\\headers_footers\\footer_igis.html",
                    open_toc = TRUE, overwrite_toc = TRUE)

Utilities for Unstitchable Images

World Files

‘World Files’ are plain-text files (also called sidecar files) with projection info for an image / dataset.

GIS software like ArcGIS Pro and QGIS use these files to display images in the proper place and size.

Generate with:

uas_worldfile(ptpinole_info)

Function options:


Output:


With World files images will just “pop” into place (approximately):

Crop Out Overlap

If your images can’t be stitched, life is not over!

This function will crop each image, keeping the center part (least distorted)

uas_cropctr(ptpinole_info)

Function options:

Example Output:

Not great, but…

Annoying Tasks: Convert file formats

Convert between JPG, TIF, and DNG without losing all the image metadata (EXIF info):

uas_convert()


In the pipeline…

Scaling for Production

Tools to get to “one flight per folder”

Make your data findable

Catalog Processed Data

Summary

The need for data management tools and workflows increases as you:


https://ucanr-igis.github.io/uasimg/