Skip to content

Instantly share code, notes, and snippets.

@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
@darrenwiens
darrenwiens / index.html
Created March 25, 2023 17:01
A frontend for a ChatGPT map-maker
<!DOCTYPE html>
<html lang="en">
<head>
<base target="_top">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ChatGPT Mapmaker</title>
@darrenwiens
darrenwiens / main.py
Last active March 26, 2023 17:51
A FastAPI that makes a request to OpenAI for LeafletJS map code
from fastapi import FastAPI
from pydantic import BaseModel
import openai
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
origins = [
"http://localhost:8001", # your allowed origin
@darrenwiens
darrenwiens / index.html
Created November 30, 2022 02:57
Mapbox single tile map client and API
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Single tile</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.js"></script>
<script src="https://unpkg.com/@turf/turf@6/turf.min.js"></script>
@darrenwiens
darrenwiens / 3dep-tile-client
Created November 27, 2022 04:40
A client for consuming 3DEP tiles from Microsoft Planetary Computer
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>3dep-tile-client</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v2.11.0/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v2.11.0/mapbox-gl.js"></script>
<style>
@darrenwiens
darrenwiens / 3dep-tile-proxy-api
Created November 27, 2022 01:48
A tile proxy server for USGS 3DEP Lidar Digital Surface Model dataset from Microsoft Planetary Computer
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from starlette.responses import StreamingResponse
import rasterio
import io
from PIL import Image
import numpy as np
app = FastAPI()
@darrenwiens
darrenwiens / index.html
Created July 6, 2022 20:42
Transparent Mapbox Globe
Blog: https://darrenwiens.github.io/transparent-mapbox-globe.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
@darrenwiens
darrenwiens / COPC_3DEP
Created July 2, 2022 18:24
A map and COPC viewer for USGS 3DEP
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>COPC 3DEP Example</title>
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<link
@darrenwiens
darrenwiens / geo_font.py
Created May 10, 2022 18:32
Geographic font
import fontforge
import json
from shapely.geometry import MultiPolygon, shape
from shapely.affinity import translate
font_file = "path/to/font.sfd" # path to sfd font file, created in FontForge GUI
geo_file = "path/to/features.geojson" # path to geographic features file
font = fontforge.open(font_file)