knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(dht)

Welcome users to DeGAUSS

greeting(
  geomarker_name = "roads",
  version = "0.1",
  description = "calculates proximity and length of nearby major roadways"
)

(Here we supplied values to use in the greeting, but from inside a DeGAUSS container these will be automatically picked up based on the environment variables that capture metadata using just dht::greeting().)

Read in geocoded data

(d <- read_lat_lon_csv('../tests/testthat/my_address_file_geocoded.csv',
sf = T, project_to_crs = 5072))

Returns a list with two elements -- the raw data and tibble nested on row (to prevent calculations with duplicate lat/lon).

Check that required columns are present

check_for_column(d, 'lat', d$lat)

Nothing is returned if the column is present. An error is thrown if the column is not present.

check_for_column(d, "nope", d$lat)

Check for column type

check_for_column(d, 'lat', d$lat, 'numeric')

Again, nothing is returned if the column type matches the desired type. A warning is displayed if the column type does not match the desired type.

check_for_column(d, 'lat', d$lat, 'character')

Check that dates are read in correctly/reformat dates

check_dates(c('1/1/21', '1/2/21', '1/3/21'))

If dates are in slash (1/1/21) or ISO (2021-01-01) format, they are returned in ISO format. If dates are in another format, a helpful error message is generated.

check_dates(c('1/1/2021', '1/2/2021', '1/3/2021'))

Write geomarker output file

Unnests the tibble created with read_lat_lon_csv() and merges back to raw data, then writes the output csv with container name and version appended to filename.

write_geomarker_file(d = d, 
                     raw_data = d, 
                     filename = 'tests/my_address_file_geocoded.csv', 
                     geomarker_name = 'roads', 
                     version = '0.1')

From inside of a DeGAUSS container, where the environment variables that capture metadata are available, this can be accomplished with just:

write_geomarker_file(d = d, raw_data = d, filename = opt$filename)


degauss-org/dht documentation built on Oct. 28, 2023, 1:20 a.m.