Skip to content

Instantly share code, notes, and snippets.

Avatar

Henry Walshaw om-henners

View GitHub Profile
@om-henners
om-henners / Calculate your 5km travel bubble.ipynb
Created Sep 6, 2020
Quick bit of Python code to calculate a 5km travel buffer given as a talk at PyConlineAU 2020!
View Calculate your 5km travel bubble.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@om-henners
om-henners / Area of Australian fires vs countries.ipynb
Created Jan 3, 2020
Compare the area burnt by Australia's fires to the area of countries and plot out a quick comparison
View Area of Australian fires vs countries.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@om-henners
om-henners / filter.jq
Last active Oct 7, 2019
jq https://stedolan.github.io/jq/ filter to transform GeoJSON Geometry Collection into Feature Collection
View filter.jq
.properties as $propertiess | {
"type": "FeatureCollection",
"features": [
(.geometries[] |
{
"type": "Feature",
"properties": (.properties + $propertiess),
"geometry": del(.properties)
}
@om-henners
om-henners / podcast_app.py
Created Jul 3, 2019
Simple flask app to dummy up a Podcast RSS feed using Flask and feedgen. Written with Python 3.7
View podcast_app.py
"""
Simple app that generates a podcasst XML feed for Radicalized
To be fair this could be easily adapted to any audiobook / set of NP3s - you'd
just need to change the image, the path to the music and all the descriptions.
Requires:
- feedgen
- flask
@om-henners
om-henners / h3_grid_generation.sh
Created Apr 28, 2019
Generate KML files for the first three levels of resolution using Uber Eng's h3 (https://github.com/uber/h3)
View h3_grid_generation.sh
mkdir -p KML
for resolution in $(seq 1 3); do
h3ToHier ${resolution} | h3ToGeoBoundary 1 res${resolution}cells.kml "Res ${resolution} Cells" > KML/res${resolution}cells.kml
h3ToHier ${resolution} | h3ToGeo 1 res${resolution}centers.kml "Res ${resolution} Centers" > KML/res${resolution}centers.kml
done
@om-henners
om-henners / serializer_utils.py
Created Nov 19, 2018
Marshmallow serializers for turning fields into GeoJSON objects based on flask-sqlalchemy and geoalchemy2
View serializer_utils.py
"""
Marshmallow wrappers to produce GeoJSON instead of a flat dictionary.
"""
from flask_marshmallow import Marshmallow
import geoalchemy2
from geoalchemy2.shape import from_shape, to_shape
from marshmallow import fields, pre_load, post_dump, ValidationError
import marshmallow_sqlalchemy as msqla
from shapely import geometry
@om-henners
om-henners / poster_text.inx
Last active Feb 14, 2017
Inkscape extension to dump source code text on a page, Lorem Ipsum style. Inspired by http://www.east5th.co/blog/2017/02/13/build-your-own-code-poster-with-elixir/ To install, drop these to files in your ~/.config/inkscape/extensions folder, restart inkscape and it's in the Extensions > Text menu.
View poster_text.inx
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>Source Code Text</_name>
<id>org.henry.poster_text</id>
<dependency type="executable" location="extensions">poster_text.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="tab" type="notebook">
<page name="Options" _gui-text="Options">
<param name="directory" type="string" _gui-text="Directory to search for code:">~/</param>
<param name="pattern" type="string" _gui-text="Filename pattern to match:">py</param>
@om-henners
om-henners / pyconau_2016_tweets.py
Last active Aug 15, 2016
Download pyconau tweets with Twython. Because of twitter's rate limiting this will take a while to execute. Also, the files wind up pretty large (~300mb per rate limited block)
View pyconau_2016_tweets.py
# coding: utf-8
from __future__ import print_function
from datetime import date, timedelta, datetime
import json
from time import sleep
from twython import Twython, TwythonRateLimitError
APP_KEY = 'YOUR_APP_KEY'
@om-henners
om-henners / arcpy_dataframe.py
Created Aug 11, 2016
Quick sample of converting an ArcGIS feature class to a pandas dataframe using arcpy.
View arcpy_dataframe.py
import arcpy
import pandas as pd
def build_df_from_arcpy(table, index_col=None):
"""
Build a pandas dataframe from an ArcGIS Feature Class.
Uses the arcpy Search Cursor to loop over a feature class in pandas and
generate a pandas dataframe. If the dataset is a feature class with a
View river_outflow.csv
station date mm
Footscray 8/3/15 0.20
Footscray 15/3/15 0.00
Footscray 22/3/15 1.60
Footscray 29/3/15 0.80
Footscray 5/4/15 0.00
Footscray 12/4/15 5.20
Footscray 19/4/15 8.00
Footscray 26/4/15 8.00
Footscray 3/5/15 0.60
You can’t perform that action at this time.