Skip to content

Instantly share code, notes, and snippets.

View ldecicco-USGS's full-sized avatar
😎

Laura DeCicco ldecicco-USGS

😎
View GitHub Profile
@ldecicco-USGS
ldecicco-USGS / baseRplot.R
Last active September 4, 2023 21:51
Base R Discharge plot of Rio Grande at Embudo, NM
library(dataRetrieval)
site <- "08279500"
discharge <- readNWISdv(site, "00060")
discharge <- renameNWISColumns(discharge)
site_info <- attr(discharge, "siteInfo")
param_info <- attr(discharge, "variableInfo")
station <- tolower(site_info$station_nm)
station <- tools::toTitleCase(station)
@ldecicco-USGS
ldecicco-USGS / Points on a map with PR
Last active March 20, 2019 15:15
Adding points to a map with AK, HI, PR
# x = data.frame with dec_long_va, dec_lat_va, state_abb, and scale columns
# dec_long_va = decimal longitude
# dec_lat_va = decimal latitude
# state_abb = 2 letter US state abbrieviation
# scale = a numeric column you are scaling by....
library(dplyr)
library(ggplot2)
# x = data.frame with dec_long_va, dec_lat_va, state_abb, and scale columns
#
@ldecicco-USGS
ldecicco-USGS / add_centered_title.R
Created September 20, 2017 19:34 — forked from sfirke/add_centered_title.R
Center all of your ggplot2 titles over the whole plot using a function
library(ggplot2)
library(grid)
library(gridExtra)
add_centered_title <- function(p, text, font_size){
title.grob <- textGrob(
label = text,
gp = gpar(fontsize = font_size)
)
library(dataRetrieval)
library(ggplot2)
library(dplyr)
sites <- c("402411077374801",
"364818094185302",
"405215084335400",
"370812080261901",
"393851077343001",
"444302070252401",
library(maps)
library(ggplot2)
library(dplyr)
library(rgdal)
library(geoknife)
library(tidyr)
library(dataRetrieval)
library(httr)
library(gganimate)
@ldecicco-USGS
ldecicco-USGS / riverslines_and_cities.R
Created July 10, 2017 17:05
Get river lines and city points and make 1 geojson
library(httr)
library(leaflet)
library(jsonlite)
# mapRange <- c(-86.32679,-81.16322,39.61600,43.06262)
# mapRange <- c(-89.560547,-97.163086, 39.731482, 43.793898)
mapRange <- c(-91.424186, -94.294625, 41.015733, 43.102420)
streamorder <- 6
filePath=NA
county.data.url <- "http://nwis.usgs.gov/awuds/nwisweb/wu_countydata"
state.data.url <- "http://nwis.usgs.gov/awuds/nwisweb/wu_statedata"
library(readr)
county.data <- read_delim(county.data.url, delim = "\t")
long.county <- gather(county.data, variable, value,
-STUDY, -USSTATEALPHACODE, -STATECODE, -COUNTYCODE,
-STATECOUNTYCODE, -COUNTYNAME, -YEAR)
@ldecicco-USGS
ldecicco-USGS / gist:ac985eb4d39f7f346188448b68ba87da
Last active September 30, 2016 21:11
Add site gages to moving state boundaries
library(USAboundaries) # contains data (shape files)
library(dplyr) # for wrangling
library(lubridate) # for wrangling dates
library(rgdal) # for wrangling shape files / map data
library(maptools) # for wrangling shape files / map data
library(ggplot2) # for plotting
library(gganimate) # for gif animation
library(viridis) # for lovely color palettes
library(dataRetrieval)
library(dataRetrieval)
library(EGRET)
siteID <- "01491000" #Choptank River at Greensboro, MD
startDate <- "1979-10-01"
endDate <- "2011-09-30"
param<-"00631"
Daily <- getDVData(siteID,"00060",startDate,endDate)
INFO<- getMetaData(siteID,param,interactive=FALSE)
INFO$shortName <- "Choptank River"
INFO <- setPA()