Skip to content

Instantly share code, notes, and snippets.

@danwild
danwild / BIG_GISTS.md
Created September 11, 2020 03:12
Gist about making gists (large files from bash)
@danwild
danwild / KML test
Created July 13, 2020 06:13
KML example for animation
<?xml version="1.0"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>1</name>
<TimeStamp>
<when>2005-08-21T09:01:00Z</when>
</TimeStamp>
<Point>
<coordinates>147.8641248483198,-41.20691100053718,650.3999223664766</coordinates>
@danwild
danwild / geojson time
Last active July 13, 2020 06:24
GeoJSON with time example
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"id": 0,
"age": 1,
"time": "2005-08-22T09:01:00Z"
},
@danwild
danwild / settings.json
Created November 28, 2019 22:13
Dump of some VSCode settings for eslint + prettier auto linting/formatting
{
"editor.tabSize": 2,
"editor.formatOnSave": true,
"workbench.colorTheme": "Darkula",
"workbench.editor.enablePreview": false,
"eslint.run": "onType",
"eslint.autoFixOnSave": true,
"liveServer.settings.donotVerifyTags": true,
"liveServer.settings.donotShowInfoMsg": true,
"javascript.updateImportsOnFileMove.enabled": "always",
@danwild
danwild / extent.py
Created May 1, 2019 04:38
Get GeoTIFF extent
import gdal
from gdalconst import GA_ReadOnly
data = gdal.Open('C:/Temp/myimage.tif', GA_ReadOnly)
geoTransform = data.GetGeoTransform()
minx = geoTransform[0]
maxy = geoTransform[3]
maxx = minx + geoTransform[1] * data.RasterXSize
miny = maxy + geoTransform[5] * data.RasterYSize
print (minx, miny, maxx, maxy)
@danwild
danwild / d3-path-animation.html
Last active April 19, 2024 08:28
D3 animate dashed paths to represent flow
<!--https://stackoverflow.com/a/39731911/1177832-->
<!DOCTYPE html>
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.js"></script>
<style>
.node {
fill: #dddddd;
stroke: gray;
@danwild
danwild / cmd.md
Created July 30, 2018 22:59
Use tree command to produce project structure diagram

-L 3 == 3 levels deep -I node_modules ignore

tree -v -L 3 --charset utf-8 -I node_modules

@danwild
danwild / subset_examples.py
Last active September 8, 2020 12:56
Crop a NetCDF file by XY, Z, and Time with CDO + python bindings
# setup
from cdo import *
cdo = Cdo()
cdo.debug = True
in_file = '/path/to/in_file.nc'
out_file = '/path/to/out_file.nc'
date1 = '2018-03-01T00:00:00'
date2 = '2018-03-01T02:00:00'
# my target is in meters
@danwild
danwild / set_extent.py
Created November 20, 2017 05:12
Set GeoTIFF extent/bounds with python GDAL
import gdal
in_file = '/Users/foo/Desktop/reproject/before.tif'
out_file = '/Users/foo/Desktop/reproject/after.tif'
# minX, minY, maxX, maxY
new_bounds = [
-78.0078239440917969,
-40.0333147430419922,
-66.0144157409667969,
let myJSON = JSON.stringify(objectToClone, function(key, value){
if(key == "troublesomeProperty"){
return undefined;
}
return value;
});