Skip to content

Instantly share code, notes, and snippets.

View tim-salabim's full-sized avatar
💭
not much

tim-salabim

💭
not much
View GitHub Profile
@tim-salabim
tim-salabim / layer_selector.R
Created February 25, 2023 13:29
layer selector
library(mapview)
library(leafem)
library(leaflet)
library(sf)
library(geojsonsf)
franc_ext <- unname(as.vector(st_bbox(franconia)))
francgj = geojsonsf::sf_geojson(franconia)
leaflet() |>
@tim-salabim
tim-salabim / snappy.qmd
Created February 15, 2023 16:22
snappy decompression issue
---
title: "snappy decompression issue"
---
```{r}
#| message: false
library(reticulate)
library(ggplot2)
library(arrow)
#!/bin/bash
url="/vsicurl/https://noaa-hrrr-bdp-pds.s3.amazonaws.com/hrrr.20220608/conus/hrrr.t00z.wrfsfcf00.grib2"
bnds="-b 62 -b 77 -b 78 -b 79 -b 9 -b 71 -b 74 -b 75 -b 107 -b 112 -b 150 -b 105 -b 106 -b 124 -b 123 -b 126 -b 125"
ext="-2097264.0 -2088264.0 713109.3 722109.3"
dmsn="9 9"
prj="EPSG:9001"
ofl="/home/tim/Downloads/novsi.tif"
#!/bin/bash
url="https://noaa-hrrr-bdp-pds.s3.amazonaws.com/hrrr.20220608/conus/hrrr.t00z.wrfsfcf00.grib2"
bnds="-b 62 -b 77 -b 78 -b 79 -b 9 -b 71 -b 74 -b 75 -b 107 -b 112 -b 150 -b 105 -b 106 -b 124 -b 123 -b 126 -b 125"
ext="-2097264.0 -2088264.0 713109.3 722109.3"
dmsn="9 9"
prj="EPSG:9001"
ofl="/home/tim/Downloads/novsi.tif"
@tim-salabim
tim-salabim / css_generator.R
Created May 1, 2021 08:46
Create custom CSS to use in popupTable
library(leaflet)
library(leafpop)
## using a custom css to style the table
className = "my-popup"
css = list(
"background" = "#ff00ff"
)
library(leaflet)
map = leaflet() %>%
addTiles()
m = htmlwidgets::onRender(
map,
jsCode = htmlwidgets::JS(
"function(el,x,data){
var map = this;
combiner = function(x, y = x) {
out = vector("list"); n = 1
for (i in x) {
for (j in y) {
# if (i %in% j) {
# next
# }
out[[n]] = c(i, j)
n = n + 1
@tim-salabim
tim-salabim / mapview_watcher.R
Created March 10, 2020 18:30
Use {later} to watch for sf objects and automatically mapview them
# This will watch your global environment for sf objects and mapview them automagically.
library(later)
library(mapview)
last_value = NULL
dir <- tempfile()
dir.create(dir)
htmlFile <- file.path(dir, "index.html")
@tim-salabim
tim-salabim / mesh3d_and_leafgl.R
Last active March 10, 2020 09:14
use leafgl to visualise mesh3d
library(ggplot2)
library(leafgl)
library(leaflet)
library(sf)
sfx <- sf::st_transform(sf::st_cast(dplyr::filter(silicate::inlandwaters, Province == "Tasmania"), "POLYGON")[2, ], 4326)
topo <- ceramic::cc_elevation(sfx, zoom = 9)
mesh <- anglr::as.mesh3d(anglr::copy_down(anglr::DEL(sfx, max_area = .0001),
library(V8)
library(mapview)
library(geojsonsf)
ct = v8(global="window")
ct$source("https://cdn.jsdelivr.net/npm/flatgeobuf@2.0.1/dist/flatgeobuf-geojson.min.js")
ct$get("Object.keys(window)")
fran = sf_geojson(franconia[1, ])