Skip to content

Instantly share code, notes, and snippets.

@darrenwiens
darrenwiens / index.html
Created April 29, 2025 16:31
Display a video derived from netcdf, all in browser
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Firesmoke Video Viewer</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v3.11.0/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v3.11.0/mapbox-gl.js"></script>
<style>
@darrenwiens
darrenwiens / geo_ligatures.py
Last active November 19, 2024 14:09
Supplements a font with ligatures of country and US state shapes. E.g. type "stateCA" -> California shape, "countryCA" -> Canada shape.
import fontforge
import json
from shapely.geometry import shape, MultiPolygon
from shapely.affinity import translate
font = fontforge.open("Arial.ttf") # font to edit
font.fullname = "Geo Ligatures"
font.familyname = "Geo Ligatures"
font.fontname = "GEO_LIGATURES"
@darrenwiens
darrenwiens / animate_crs.py
Created October 4, 2024 18:03
Rotate a globe in QGIS by updating the crs
from PyQt5.QtCore import QTimer
from qgis.core import QgsCoordinateReferenceSystem
from qgis.utils import iface
current_index = 0
def update_crs():
global current_index
custom_proj = f"+proj=ortho +lat_0=0 +lon_0={current_index} +x_0=0 +y_0=0 +ellps=sphere +units=m +no_defs +type=crs"
custom_crs = QgsCoordinateReferenceSystem()
@darrenwiens
darrenwiens / simcity_bridges.txt
Created September 21, 2024 00:51
QGIS Geometry Generator for SimCity Style Bridges
-- add this to a road LINE layer that also has
-- a geometry geometry applied that buffers it
-- by 1000m. That's wide, I know!
-- change the reference to your water layer below.
-- all layers must be in a projected crs.
collect_geometries(
array_foreach(
geometries_to_array(
intersection(
@darrenwiens
darrenwiens / wave.txt
Last active September 21, 2024 07:14
QGIS geometry generator expression for creating an animated wave effect
-- qgis geometry generator expression
-- to be used in water polygon layer
-- water polygons must be in a projected CRS
-- enable animation on the layer
-- change geometry generator geometry type to linestring
intersection(
$geometry,
translate(
wave_randomized(
collect_geometries(
@darrenwiens
darrenwiens / main.py
Last active July 2, 2024 18:28
A FastAPI for generating ascii map tiles (png)
# MIT License
# Copyright (c) 2024 Darren Wiens
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@darrenwiens
darrenwiens / index.html
Created April 29, 2024 23:55
High Res Canopy Height COG viewer
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>High Resolution Canopy Height</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v3.2.0/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v3.2.0/mapbox-gl.js"></script>
<style>
@darrenwiens
darrenwiens / index.html
Created February 25, 2024 00:59
A Potree static site for showing COPCs from Microsoft Planetary Computer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>MPC COPC Viewer</title>
@darrenwiens
darrenwiens / maps.js
Created February 19, 2024 17:53
Add Tetris to Mapbox GL JS
mapboxgl.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
let center = [-74.5, 40]
const map = new mapboxgl.Map({
container: 'map',
center: [-74.426, 40.1792],
zoom: 9,
pitch: 50,
keyboard: false,
preserveDrawingBuffer: true,
});
@darrenwiens
darrenwiens / jupytercad_mr_pg.ipynb
Created June 2, 2023 22:32
Draw Mr. PG with jupytercad
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.