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
addGlobeControl = function(map) {
let globecontrol = new maplibregl.GlobeControl();
map.addControl(globecontrol);
return map;
}
addDeckGlPolygons = function(map, geom_column_name, layerId) {
let gaDeckLayers = window["@geoarrow/deck"]["gl-layers"];
let data_fl = document.getElementById(layerId + '-1-attachment');
fetch(data_fl.href)
.then(result => Arrow.tableFromIPC(result))
.then(arrow_table => {
let geoArrowPolygon = new gaDeckLayers.GeoArrowPolygonLayer({
id: layerId,
@tim-salabim
tim-salabim / add_deckgl_polygons.R
Last active February 5, 2025 19:01
add deckgl polygonLayer to a maplibre map using mapgl. Utilizes the blazing fast data transfer via arrow IPC stream
add_deckgl_polygons = function(
map
, data
, layerId
, geom_column_name = attr(data, "sf_column")
) {
path_layer = tempfile()
dir.create(path_layer)
path_layer = paste0(path_layer, "/", layerId, "_layer.arrow")
@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