Skip to content

Instantly share code, notes, and snippets.

View smnorris's full-sized avatar

Simon Norris smnorris

View GitHub Profile
@blacha
blacha / docker-gdal.sh
Created November 6, 2021 22:26
Run GDAL in $PWD from docker
#!/bin/bash
CUID=$(id -u)
CGID=$(id -g)
# Run docker as the current user in the current diretory
docker run \
--user $CUID:$CGID \
--volume $PWD:$PWD \
--workdir $PWD \
--rm \

Important

DO NOT USE VSCODE terminal and make sure uname -m returns arm64

  1. First Install Xcode command line tool
xcode-select --install
  1. Create and change /opt directories owner

Install CURL with HTTP/2 support

$ brew install nghttp2
$ brew uninstall curl --force --ignore-dependencies

# Due to recent change to curl formula we need to use an old version 
# more https://github.com/Homebrew/homebrew-core/issues/31510
#
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/ec361bc7710ffffa46ad7aceb76bfad8513a7399/Formula/curl.rb … --with-nghttp2 --HEAD
@sgillies
sgillies / advanced_rasterio_features.ipynb
Last active October 19, 2024 17:20
Advanced Rasterio features notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wboykinm
wboykinm / turf_and_vts.md
Last active April 15, 2024 14:57
Learnings while geoprocessing vector tiles with turf.js
@david-murr
david-murr / gist:9d17e4b7267ab3290833
Last active December 14, 2018 22:52
command line raster stats
fio cat ../missed.shp | rio zonalstats -r amfam.vrt --categorical | jq '.features[].properties | {APN: .APN,pool: ._1}' | jq --slurp . | in2csv -f json > test.csv
jq '.features[].properties | {APN: .APN,pool: ._1}' pools.geojson | jq --slurp . | in2csv -f json > test.csv
fio cat countries.shp | rio zonalstats -r dem.tif --prefix "elevation_" > countries_with_elevation.geojson
fio cat large.shp | rio zonalstats -r elevation.tif --sequence | some-other-process
time fio cat ../parcels/parcels_pools.shp | parallel --pipe "rio zonalstats -r amfam.vrt --categorical" > out
fio cat test.shp | jq '{geometry: .geometry, PARCEL_ID: .properties.PARCEL_ID}' -c | fio collect > test.geojson
@maphew
maphew / dnld-yt-nhn.cmd
Created December 3, 2015 19:37
Download National Hydrographic Network for Yukon Territory and surround
@echo off
:: rev 0.1 2008.Mar.10, Matt.Wilkie@gov.yk.ca
:: rev 0.2 2008.Sept.18 - updated to account for change in ftp source folders
:: rev 0.3 2014.Feb.06 - enable timestamp (only download if source newer)
echo.
echo. -----------------------------------------------------------------------
echo. Going to download National Hydrographic Network Yukon, which could take
echo. awhile. This script can be aborted and rerun, it will resume
echo. where it left off.
echo. -----------------------------------------------------------------------
@jennybc
jennybc / 2014-12-01_finessing-excel-line-endings.md
Last active November 17, 2022 13:04
Finessing Excel's stupid line endings

Finessing Excel's stupid line endings

I am sheepish to admit a certain type of routine Microsoft Excel use.

Current example: I am marking for STAT 545. I use R to create a comma delimited marking sheet, by joining the official class list and peer reviews. The sheet contains variables, initially set to NA, where the TAs and I enter official marks and optional comments.

This is where Excel comes in. I like its visual organization of this comma delimited file much more than, say, using a plain text editor. I use the ability to hide columns, resize columns, wrap text, and (gasp!) even fill rows with grey to indicate I am done.

I keep saving the file as comma delimited and I put up with Excel's incessant freak out about "losing features". This is not a one time thing. I need to save and commit this file many times before it is considered done.

#!/bin/bash
# rename TMS tiles to the XYZ schema
# no quoting, since all files have simple numeric names
# do not run this anywhere else than INSIDE your tiles directory
# run it like this: find . -name "*.png" -exec ./tms2xyz.sh {} \;
filename=$1
tmp=${filename#*/} # remove to first /