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
############################################################### | |
# Code to publish interpolated temperature map # | |
# based on current observations from the # | |
# Israel Meteorological Service (IMS) website # | |
# Author: Michael Dorman # | |
############################################################### | |
library(XML) | |
library(httr) | |
library(plyr) |
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
loocv = function(formula, data) { | |
pred = rep(NA, nrow(data)) | |
for(i in 1:nrow(data)) { | |
fit = lm(formula = formula, data = data[-i, ]) | |
pred[i] = predict(fit, data[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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Simple Leaflet Map</title> | |
<meta charset="utf-8" /> | |
<link | |
rel="stylesheet" | |
href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" | |
/> | |
</head> |
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
# Directory with R scripts | |
setwd("~/Sync/BGU") | |
# Prepare data | |
files = list.files(pattern = "\\.R$", recursive = TRUE) | |
dat = lapply(files, readLines) | |
dat = lapply(dat, function(x) x[grepl("library\\(", x)]) | |
dat = lapply(dat, function(x) gsub(".*library\\(", "", x)) | |
dat = lapply(dat, function(x) gsub("\\).*", "", x)) | |
dat = lapply(dat, function(x) gsub('"', '', x)) |
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(sf) | |
library(ggplot2) | |
# Data | |
nc = st_read(system.file("shape/nc.shp", package="sf")) | |
map = nc | |
dat = nc[5, ] | |
# Plot 1 | |
ggplot() + |
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(sf) | |
library(osmdata) | |
location = "Tel-Aviv, Israel" | |
# Get data | |
q = opq(bbox = location) | |
dat = add_osm_feature(q, key = "highway") | |
dat = osmdata_sf(dat) | |
lines = dat$osm_lines |
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
// US area polygon | |
var pol = ee.Geometry.Polygon([ [ [ -80.919630492025277, 30.699135009797704 ], [ -80.871245451372644, 30.336014265533166 ], [ -80.762754341973988, 29.906426353226227 ], [ -80.504997201528766, 29.330160083879278 ], [ -80.083106700408266, 28.673401576509857 ], [ -80.070233511479728, 28.651960676800226 ], [ -80.058638153313169, 28.629988680787292 ], [ -80.04835227119456, 28.607547474440747 ], [ -80.039403769248054, 28.584700211077717 ], [ -80.031816742625793, 28.561511131077758 ], [ -80.025611421049575, 28.538045379128882 ], [ -80.020804123732901, 28.514368819546309 ], [ -80.0174072256752, 28.490547850204102 ], [ -80.01542913528462, 28.466649215616201 ], [ -80.0148742832517, 28.442739819698442 ], [ -80.015743122564871, 28.418886538736928 ], [ -80.018032139528088, 28.395156035079435 ], [ -80.021733875613705, 28.371614572058188 ], [ -80.026836959956768, 28.348327830641338 ], [ -80.033326152273503, 28.32536072829911 ], [ -80.041182395964384, 28.302777240558235 ], [ -80.050382881141516, 28.2806402 |
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(stars) | |
library(classInt) | |
# Data | |
r = read_stars(system.file("tif/L7_ETMs.tif", package = "stars")) | |
# Plot | |
b = classIntervals(r[[1]], 10, "equal") | |
b = b$brks | |
for(i in 1:dim(r)[3]) { |
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(stars) | |
multipoint = st_as_sfc("MULTIPOINT ((10 40), (40 30), (20 20), (30 10))")[[1]] | |
multilinestring = st_as_sfc("MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))")[[1]] | |
multipolygon = st_as_sfc("MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))")[[1]] | |
dat = c(st_sfc(multipoint), st_sfc(multilinestring), st_sfc(multipolygon)) | |
dat = st_sf(dat, data.frame(value = 1, type = c("Points", "Lines", "Polygons"))) | |
grid = st_as_stars(st_bbox(st_buffer(dat, 3)), dx = 3, dy = 3) |
OlderNewer