Instantly share code, notes, and snippets.

View elvis_1m_dem_bbox.sh
wget -O - https://elvis-ga.fmecloud.com/fmedatastreaming/elvis_indexes/ReturnDownloadables.fmw | jq -r '.available_data[].downloadables.DEMs."1 Metre"[].bbox' | xargs -I '{}' turf bboxPolygon "[{}]" | tr -d '\n ' | sed 's/}{/},{/' | sed 's/^/{"type": "FeatureCollection", "features": [/' | sed 's/$/]}/' > elvisBBOX.geojson
View main.sh
wget https://s3-ap-southeast-2.amazonaws.com/opendata-aerial-imagery/mga55_gda94_10cm_2018_CoM_true_ortho.zip
unzip mga55_gda94_10cm_2018_CoM_true_ortho.zip
rm mga55_gda94_10cm_2018_CoM_true_ortho.zip
gdalwarp -multi -wo NUM_THREADS=ALL_CPUS -r lanczos -t_srs 'EPSG:3857' -co COMPRESS=JPEG -co TILED=YES mga55_gda94_10cm_2018_CoM_true_ortho/mga55_gda94_10cm_2018_CoM_true_ortho.jp2 CoM_10cm_May_2018_EPSG3857.tiff
# the alpha band is being misunderstood by most software, creating a transpaent image, so we can just ignore the alpha band
gdal_translate -co COMPRESS=JPEG -b 1 -b 2 -b 3 CoM_10cm_May_2018_EPSG3857.tiff CoM_10cm_May_2018_EPSG3857_RGB.tiff
# You may find it easier to run this on the Docker image at https://hub.docker.com/r/klokantech/gdal/ which has various JP2 drivers installed
# docker run -ti --rm -v $(pwd):/data klokantech/gdal gdalwarp ...
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Mapbox GL Draw Rectangle</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.49.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.49.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>NSW 1943 vs now</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.49.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.49.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
View isochrone.js
#!/usr/bin/env node
var process = require('process');
process.env.UV_THREADPOOL_SIZE = Math.ceil(require('os').cpus().length * 1.5);
var OSRM = require('osrm');
var path = require('path');
var fs = require('fs');
var d3 = require('d3');
var async = require('async');
View 34M_17.bin
This file has been truncated, but you can view the full file.
View README.md
View README.md
  • Download the ASGS SA1 Shapefiles

  • Download the latest GNAF from OpenAddresses (choose the Output file)

  • psql -c 'CREATE EXTENSION postgis;'

  • Load the address points ogr2ogr -f PostgreSQL -select 'ID' PG: au/countrywide.vrt -nln oa -lco UNLOGGED=YES

  • Load the ASGS SA1 ogr2ogr -f PostgreSQL -t_srs 'EPSG:4326' PG: SA1_2016_AUST.shp -nln sa1 -lco UNLOGGED=YES -nlt PROMOTE_TO_MULTI

  • Generate the address weighted centroid of each SA1. psql -f sa1_oa_weighted_centroids.sql

  • Output to CSV ogr2ogr -f 'CSV' sa1_oa_weighted_centroid.csv PG: sa1_gnaf_weighted_centroids -lco GEOMETRY=AS_XY

View geojsonDumbMerge.sh
#!/bin/sh
echo '{"type": "FeatureColletion", "features": [' > head.json
echo ']}' > foot.json
echo ',' > comma.txt
for f in *.geojson.gz ; do cat $f | gunzip | tail -n+2 | head -n -1 | cat - comma.txt > tmp/$f ; done
cat head.json tmp/* | head -c -4 | cat - foot.json > merged.geojson
View main.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.