Skip to content

Instantly share code, notes, and snippets.

Andrew Harvey andrewharvey

Block or report user

Report or block andrewharvey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andrewharvey
andrewharvey / index.html
Created Sep 27, 2019
Mapbox GL JS look at elevation example
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Look at Elevation</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.3.2/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.3.2/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
View polygon-with-a-hole.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View polygon-clipping-bug.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Display a map</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.1.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.1.1/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@andrewharvey
andrewharvey / mbgl-offline-geojson-tiles
Created Mar 4, 2019
Inspect an mbgl-offline pack and generate a GeoJSON of the containing tiles
View mbgl-offline-geojson-tiles
#!/bin/sh
sqlite3 -separator ',' offline.db 'select x,y,z from tiles;' | sed 's/^/[/' | sed 's/$/]/' | mercantile shapes --indent 2 > offline.tiles.geojson
View index.html
<!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 Jan 2, 2019
Dargans Creek Reserve
View Makefile
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
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
@andrewharvey
andrewharvey / main.sh
Last active Sep 26, 2018
Melbourne May 2018 Imagery
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 ...
You can’t perform that action at this time.