Skip to content

Instantly share code, notes, and snippets.

View mbjoseph's full-sized avatar

Max Joseph mbjoseph

View GitHub Profile
@mbjoseph
mbjoseph / main.ipynb
Created January 16, 2017 21:41
sad error
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbjoseph
mbjoseph / HDF_to_TIF.R
Created March 10, 2017 20:36
Setting raster projections, extent, and computing annual summaries
library(rgdal)
library(rgeos)
library(raster)
library(gdalUtils)
# gdalinfo("GFED40_MQ_199506_BA.hdf")
# sds <- get_subdatasets("GFED40_MQ_199506_BA.hdf")
# sds
@mbjoseph
mbjoseph / read_ams_data.R
Created March 29, 2017 20:24
Parse and read ams data
# Importing data from USDA into large data file ---------------------------
library(stringr)
library(tidyverse)
convert_to_df <- function(file) {
# takes a text file as input and parses the file to generate a data.frame
lines <- readLines(file)
# identify blank lines which denote separate files
@mbjoseph
mbjoseph / boulder-weather-basis.R
Created May 19, 2017 19:39
Using basis functions to predict weather in Boulder, CO
library(raster)
library(tidyverse)
library(lubridate)
library(mgcv)
# Boulder temperature prediction ------------------------------------------
# Goal: use historical temperature data to predict the weather a week from today
# Fetch raw data from NOAA
data_url <- "https://www.esrl.noaa.gov/psd/boulder/data/boulderdaily.complete"
@mbjoseph
mbjoseph / hello-world.R
Created June 5, 2017 20:24
Hello world in R
print("Hello, world!")
@mbjoseph
mbjoseph / get_lsat.rasters.R
Last active June 7, 2017 19:51
Fetch rasters from USGS server
library(RCurl)
# Fetching burn rasters ---------------------------------------------------
# get and read the file listing from the usgs server
prefix <- 'https://rmgsc.cr.usgs.gov/outgoing/baecv/BAECV_CONUS_v1_2017/'
download.file(prefix, destfile = 'listing.txt')
out <- readLines('listing.txt')
# now create paths to each tar.gz file by processing the html

Keybase proof

I hereby claim:

  • I am mbjoseph on github.
  • I am mbjoseph (https://keybase.io/mbjoseph) on keybase.
  • I have a public key ASABiVndWu_-6CJIwyKMRAlsmF3sEsWB33XMDPoZ2GAbvAo

To claim this, I am signing this object:

@mbjoseph
mbjoseph / bivar_pois.R
Last active September 2, 2018 18:12
Initial pass at a bivariate Poisson model in Stan
## Simple bivariate Poisson model in stan
## following parameterization in Karlis and Ntzoufras 2003
## Simulate data
n <- 50
# indpendent Poisson components
theta <- c(2, 3, 1)
X_i <- array(dim=c(n, 3))
for (i in 1:3){
@mbjoseph
mbjoseph / blogpost.Rmd
Created September 14, 2018 19:25
smapr Ropensci blog post
---
title: 'Mapping the 2018 East Africa floods from space with smapr'
author: "Max Joseph"
date: "2018-09-14"
output:
html_document:
keep_md: yes
---
```{r setup, include=FALSE}
@mbjoseph
mbjoseph / earthpy-data-gen.R
Last active December 16, 2018 16:31
Example data generation for earthpy
library(tidyverse)
library(raster)
library(sf)
library(rmapshaper)
library(elevatr)
library(USAboundaries)
dir.create('out')
# RGB satellite imagery over Rocky Mountain National Park -------------