Skip to content

Instantly share code, notes, and snippets.

View andrewharvey's full-sized avatar

Andrew Harvey andrewharvey

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>Mapbox GL JS debug page</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.1/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
@andrewharvey
andrewharvey / Makefile
Created January 2, 2019 21:36
Dargans Creek Reserve
query.sql: parcels.txt
cat parcels.txt | sed 's/Lot /(lotnumber = \'/' | sed -E 's/ DP ?/\' and plannumber = /' | sed 's/$/) or /' | tr -d '\n' | sed 's/ or $//'> query.sql
reserve.geojson:
wget -O reserve.geojson 'https://maps.six.nsw.gov.au/arcgis/rest/services/public/NSW_Cadastre/MapServer/9/query?where=%28lotnumber+%3D+%272%27+and+plannumber+%3D+778317%29+or+%28lotnumber+%3D+%277014%27+and+plannumber+%3D+1020484%29+or+%28lotnumber+%3D+%277311%27+and+plannumber+%3D+1154270%29+or+%28lotnumber+%3D+%277312%27+and+plannumber+%3D+1154269%29+or+%28lotnumber+%3D+%277313%27+and+plannumber+%3D+1154269%29+or+%28lotnumber+%3D+%277301%27+and+plannumber+%3D+1123766%29+or+%28lotnumber+%3D+%277033%27+and+plannumber+%3D+1051528%29+or+%28lotnumber+%3D+%277015%27+and+plannumber+%3D+1051527%29+or+%28lotnumber+%3D+%271%27+and+plannumber+%3D+778317%29+or+%28lotnumber+%3D+%277018%27+and+plannumber+%3D+1051736%29+or+%28lotnumber+%3D+%277019%27+and+plannumber+%3D+1051736%29+or+%28lotnumber+%3D+%27266%27+and+plannumber+%3D+7516
@andrewharvey
andrewharvey / elvis_1m_dem_bbox.sh
Created December 13, 2018 01:07
ELVIS 1m DEM bbox
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
@andrewharvey
andrewharvey / main.sh
Last active September 26, 2018 09:08
Melbourne May 2018 Imagery
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 ...
@andrewharvey
andrewharvey / index.html
Created September 25, 2018 03:52
Mapbox GL Draw Rectangle
<!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; }
@andrewharvey
andrewharvey / index.html
Created September 17, 2018 01:40
NSW 1934 vs now
<!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; }
@andrewharvey
andrewharvey / isochrone.js
Created September 3, 2018 14:07
OSRM Isochrones
#!/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');
@andrewharvey
andrewharvey / 34M_17.bin
Last active April 21, 2020 09:15
Add 3D model to a Mapbox GL JS map
This file has been truncated, but you can view the full file.
@andrewharvey
andrewharvey / README.md
Created July 29, 2018 04:22
Distance table between CSV coordinates using OSRM
@andrewharvey
andrewharvey / README.md
Created July 29, 2018 01:02
Address weighted SA1 centroids
  • 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