Skip to content

Instantly share code, notes, and snippets.

@jpshanno
jpshanno / earth_explorer_functions.R
Created February 9, 2021 02:09
Lightweight Functions to Download Machine-to-Machine Earth Explorer Data
# Functions inspired by espa.tools espa_inventory_post_api
# getSpatialData provides similar functionality, but is larger & slower than
# what I need
library(httr)
library(jsonlite)
library(parallel)
build_request <-
function(target, ...){
base_url <- "https://m2m.cr.usgs.gov/api/api/json/stable/"
@jpshanno
jpshanno / download_ncei_hourly_precip_data.R
Last active March 22, 2021 14:33
Download Hourly Precipitation Data with the US
# Download and format data from the NOAA NCEI Hourly Precipitation Data Network
# Limit sites by radius from a pair of coordinates and by bounding dates
# See the README for the dataset for more information
# https://www.ncei.noaa.gov/data/coop-hourly-precipitation/v2/doc/readme.csv.txt
# The script will download the CSVs limited spatially or temporally and will return
# three datatables containing the hourly dataset, daily dataset, and the station
# coordinates and elevation.
# Downloaded data are saved to the provided directory using the station name,
# not station ID
@jpshanno
jpshanno / custom_mutate.md
Created October 9, 2018 17:08
Custom Mutate Functions that Respect Groups
library(dplyr)
#> Warning: package 'dplyr' was built under R version 3.5.1
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
@jpshanno
jpshanno / exported_absorbance_96_wells.txt
Created July 20, 2018 02:00
Plate Reader Ingest Demo
##BLOCKS= 8
Note:
~End
Plate: Plate#1 1.3 PlateFormat Endpoint Absorbance Raw FALSE 1 1 610 1 12 96 1 8 None
Temperature(�C) 1 2 3 4 5 6 7 8 9 10 11 12
22.20 0.0675 0.067 0.0701 0.256 0.3226 0.3276 0.0654 0.0646 0.0668 0.0644 0.0655 0.0705
0.0771 0.0665 0.0739 0.0578 0.0724 0.061 0.0749 0.0703 0.0672 0.0739 0.0843 0.0808
0.0878 0.0824 0.0853 0.0564 0.0637 0.0609 0.066 0.0594 0.0639 0.0624 0.0704 0.0671
0.0815 0.0684 0.0739 0.0604 0.0729 0.06 0.0682 0.0601 0.0651 0.0608 0.0688 0.0626
0.1321 0.1215 0.1385 0.0586 0.0687 0.0625 0.0656 0.0585 0.0645 0.0576 0.0699 0.0633
@jpshanno
jpshanno / View_Campell_Dat.R
Created June 13, 2018 04:07
Shiny DataViz For Multi-Sensor Campbell Data File
# This can be run in Rstudio and will display in the Viewer tab with a file input box.
# As it is written it only reads in Campbell Scientific *.dat files, but changing line 34 would solve that.
library(dplyr)
library(lattice)
library(miniUI)
library(readr)
library(shiny)
library(shinyjs)
library(tidyr)