This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get DPIRD CVT zones from the Public Services Slip WA as an {sf} object in R | |
# data are CC 4.0 and available from: <https://data.wa.gov.au/slip> | |
wfs_wa <- | |
"https://public-services.slip.wa.gov.au/public/services/SLIP_Public_Services/Boundaries_WFS/MapServer/WFSServer" | |
url <- httr2::url_parse(wfs_wa) | |
url$query <- list(service = "wfs", | |
#version = "2.0.0", # facultative | |
request = "GetCapabilities") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fetch historical weather data with Python using various packages | |
# use plotnine for graphing | |
from plotnine import * | |
import pandas as pd | |
import pathlib | |
# pynasapower | |
# Fetches NASA POWER data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("nasapower") | |
library("purrr") | |
library("dplyr") | |
df <- data.frame( | |
stringsAsFactors = FALSE, | |
lon = c(151.81, 112.5, 115.5), | |
lat = c(-27.48, -55.5, -50.5), | |
date = c("3/3/2023", "5/12/2023", "1/3/2024") | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Project '~/tmp/OceanOmics-classifier-comparison' loaded. [renv 1.0.3] | |
> targets::tar_make() | |
> dispatched target all_results_files | |
o completed target all_results_files [0 seconds] | |
> dispatched branch all_results_ecfccd47 | |
o completed branch all_results_ecfccd47 [0 seconds] | |
> dispatched branch all_results_eccc5a34 | |
o completed branch all_results_eccc5a34 [0 seconds] | |
> dispatched branch all_results_05574669 | |
o completed branch all_results_05574669 [0 seconds] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get all DPIRD boundary data sets available from the Public Services Slip WA and save data for use in an R package. | |
# HT to Thierry Onkelinx, Hans Van Calster, Floris Vanderhaeghe for their post, | |
# <https://inbo.github.io/tutorials/tutorials/spatial_wfs_services/>, but I | |
# modified this to work to save .Rds files for use in an R package, not just | |
# saving to disk and chose to use {httr2} in place of {httr}. | |
# NOTE: This URL is only for public boundaries, | |
<https://public-services.slip.wa.gov.au/public/services/SLIP_Public_Services/Boundaries_WFS/MapServer/WFSServer>, | |
there are others, see <https://catalogue.data.wa.gov.au/dataset> for other orgs and types of data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find stations in both the DPIRD and SILO weather station networks given a | |
# vector of locations or capture messages when no stations are found | |
library("tidygeocoder") | |
library("data.table") | |
library("weatherOz") | |
library("purrr") | |
# Step 1: Create a vector of named locations to geocode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StatQuantileBin <- ggplot2::ggproto("StatQuantileBin", ggplot2::StatBin, | |
default_aes = ggplot2::aes(x = ggplot2::after_stat(density), y = ggplot2::after_stat(density), weight = 1), | |
compute_group = function(data, scales, | |
binwidth = NULL, bins = 30, breaks = NULL, trim = 0, | |
closed = c("right", "left"), pad = FALSE, | |
flipped_aes = FALSE, | |
# The following arguments are not used, but must | |
# be listed so parameters are computed correctly | |
origin = NULL, right = NULL, drop = NULL, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download any data file from a private GitHub repo | |
# regardless of how large it is. | |
# Returns a string that will then need to be parsed | |
# by read_csv or the like to turn it into a data frame. | |
# Dependencies | |
require(tidyverse) | |
require(httr) | |
require(rlist) | |
require(jsonlite) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Entering data | |
week <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) | |
YLI <- c(3, 4, 5, 2, 6, 5, 4, 3, 5, 6, 2, 4) | |
YLS <- c(10, 11, 11, 12, 10, 11, 11, 10, 12, 13, 10, 11) | |
rainfall <- c(1, 10, 8, 6, 65, 30, 2, 10, 8, 6, 65, 30) | |
# Creating Data Frame | |
perf <- data.frame(week, YLI, YLS, rainfall) | |
# Plotting Charts and adding a secondary axis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function audpc(evaluation, dates) | |
n = length(evaluation) - 1 | |
disvec = Base.zeros(n) | |
datevec = Base.zeros(n) | |
out = 0.0 | |
for i in 1:n | |
disvec[i] = (evaluation[i] + evaluation[i + 1]) / 2 | |
datevec[i] = dates[i + 1] - dates[i] | |
out = sum(disvec .* datevec) |
NewerOlder