library(sf)
#> Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0
system("ogr2ogr --version", intern = TRUE)
#> [1] "GDAL 2.4.2, released 2019/06/28"
system("proj", intern = TRUE)
#> character(0)
file <- system.file("gpkg/tl.gpkg", package = "sf")
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
*.png | |
.DS_Store | |
.Rhistory |
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
# install.packages(c("bcdata", "dplyr", "remotes")) | |
# remotes::install_github("bcgov/rems") | |
library(rems) | |
library(bcdata) | |
library(dplyr) | |
# Get the watershed boundary - I don't know if this is exactly the boundary you | |
# want but you could read in any spatial file you have instead using the sf package. Eg: | |
# columbia <- sf::read_sf("path-to-my-columbia-boundary.shp") | |
columbia <- bcdc_query_geodata("eaubc-freshwater-ecoregions") %>% |
locations <- data.frame(id = "E309447")
library(rems)
library(dplyr)
hist_db <- attach_historic_data()
filtered_historic <- hist_db %>%
filter(EMS_ID %in% locations$id) %>%
collect()
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
# If you haven't installed homebrew, see some instructions here: | |
# https://github.com/bcgov/envreportutils/wiki/Macbook-Pro-Setup-for-Data-Science-at-EnvReportBC#homebrew | |
# These have not been tested on macOS Catalina, but the Mojave instructions _should_ work. | |
# If you run into issues, this looks like it might be helpful: | |
# https://medium.com/faun/macos-catalina-xcode-homebrew-gems-developer-headaches-cf7b1edf10b7 | |
# The osgeo homebrew tap is in a bit of a mess, so `brew install saga-gis` doesn't work (as of 2019-10-30). | |
# This is because SAGA dependencies have been updated, but they haven't updated the brew formula for SAGA itself. | |
# Same goes for QGIS; and now that there is a fully self-contained signed installer, I recommend that over heomebrew for QGIS | |
# (https://qgis.org/en/site/forusers/download.html) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
## First make up some mock data | |
my_data <- data.frame(date = seq(as.Date("2010-01-01"), as.Date("2015-12-31"), | |
by = "1 month"), | |
value = rnorm(72)) | |
## Remove some observations so we have an incomplete data set | |
my_incomplete_data <- my_data[sort(sample(nrow(my_data), 60)), ] | |
## Make a data frame with a full series of dates from the min date to the max date | |
## in the incomplete data frame |
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
## | |
# osgeo/gdal:ubuntu-full | |
# This file is available at the option of the licensee under: | |
# Public domain | |
# or licensed under X/MIT (LICENSE.TXT) Copyright 2019 Even Rouault <even.rouault@spatialys.com> | |
# ACT: Copied from https://raw.githubusercontent.com/OSGeo/gdal/master/gdal/docker/ubuntu-full/Dockerfile | |
ARG PROJ_INSTALL_PREFIX=/usr/local |
values <- runif(100)
# get runs where values > 0.75 (these are TRUE/FALSE)
runs <- rle(values > 0.75)
# Mask out the runs with lengths < 3
runs$values[runs$lengths < 3] <- FALSE
# Get a vector of positions that meet the run criteria
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
values <- runif(100) | |
# get runs where values > 0.75 (these are TRUE/FALSE) | |
runs <- rle(values > 0.75) | |
# Mask out the runs with lengths < 3 | |
runs$values[runs$lengths < 3] <- FALSE | |
# Get a vector of positions that meet the run criteria | |
masked <- inverse.rle(runs) |