Skip to content

Instantly share code, notes, and snippets.

@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.
@darrenwiens
darrenwiens / dem_to_oblique.ipynb
Created May 15, 2023 22:26
A notebook demonstrating how to create an oblique horizon plot, given a digital elevation model and observer point.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@darrenwiens
darrenwiens / main.py
Created April 6, 2023 20:20
Segment anything API, segments static Mapbox Satellite Image
from fastapi import FastAPI
from pydantic import BaseModel
import torch
import torchvision
import numpy as np
from PIL import Image
import random
import requests
import base64
import io