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
#This is a plumber api for setting up a basic pixel tracker | |
# here's a random page I found about what pixel trackers are: https://en.ryte.com/wiki/Tracking_Pixel | |
# When the pixel is loaded by an embedded image eg. | |
# | |
# <img src="baseurl.com/pixel?log=this_is_the_message_I_want_to_log" > | |
# | |
# It creates a new folder for the date if needed then writes a log file into the folder | |
library(plumber) | |
library(png) |
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
packages <- as.data.frame(installed.packages()) | |
for (i in 1:length(packages$Package)){ | |
try({ | |
library(packages$Package[i], character.only = TRUE) | |
}) | |
print(packages$Package[i]) | |
} |
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
#load pacakges | |
library(sf) | |
library(magrittr) #for the pipe | |
#create a test dataframe | |
test <- expand.grid(latitude = 50:52,longitude = -1:1) | |
#load as sf, transform, round to 1km | |
test2 <- st_as_sf(test,coords =c("longitude","latitude"),crs = 4326) %>% | |
st_transform(27700) %>% |
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
n <- 1004 | |
for(i in 1:n){ | |
Sys.sleep(0.2 | |
cat("\r",round(i/n*100,2),"%") | |
} |
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
# this script provides 1km gridded data on how accessible the grid square is by the proportion of 100m grid cells within it are accessible by footpath. | |
#rationale: | |
#OSM data is really rich and detailed but sometimes you need gridded summaries in raster format. This example shows to generate a raster with the proportional coverage within 1km grid squares containing footpaths. And a second example with the save proportional coverage but for car parks as an indication of how much parking there is in a 1km grid cell. | |
#These are metrics/indices and act as coarser approximations | |
#load packages | |
library(osmextract) | |
library(magrittr) # for %>% |
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
// Load a landsat image and select three bands. | |
var landsat = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_123032_20140515') | |
.select(['B4', 'B3', 'B2']); | |
// Create a geometry representing an export region. | |
var geometry = ee.Geometry.Rectangle([-4.477366, 56.740975, -2.800270, 57.410659 ]); | |
Map.addLayer(geometry, {palette: 'FF0000'}, "Study Area"); | |
// predictor variables |
Loading
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
library(httr) | |
library(jsonlite) | |
library(dplyr) | |
# Get a list of data providers | |
response <- GET("https://registry.nbnatlas.org/ws/dataProvider") | |
content <- content(response, "text") | |
data_providers <- fromJSON(content) # Parse the JSON response into a dataframe | |
#define query |
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
--- | |
title: "MAMBO sim framework tests" | |
author: "Simon Rolph" | |
date: "`r Sys.Date()`" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` |
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
# This is an example r {targets} workflow it does the following: | |
# | |
# (0. (Generate some example data) | |
# 1. Statically branch to create data subsets for each species | |
# 2. Fit a linear model to each of the species subset | |
# 3. Produce and save a plot of each species trend (with a line from the linear model) using tar_map() | |
# 4. Produce and save a plot with all of the species combined and their linear models using tar_combine() | |
#this is combined into a single file for sharability but normally you'd have the R functions in another .R file |
OlderNewer