Skip to content

Instantly share code, notes, and snippets.

@om-henners
om-henners / geojson_handler.py
Created November 12, 2012 23:59
Replacement for arcpy.AsShape function as it doesn't work...
'''
Helper class to read and write geojson objects in ArcGIS as a replacement for
the arcpy.asShape(geojson) function. Requires ArcGIS installation...
Creation includes creating a geojson object from an ArcGIS feature class,
feature or geometry.
Reading is more complex. This module includes support for Feature Collections,
Features and Geometry. All geometry types are supported except for
GeometryCollection which is unsupported by ArcGIS. Feature collections must have
@om-henners
om-henners / aus_polling_places.py
Created September 6, 2013 00:58
From a CSV which you can download from the [AEC](http://www.aec.gov.au/) generate a GeoJSON file containing locations of polling places in your electorate. See example output for the [Melbourne electoral division](http://www.aec.gov.au/profiles/vic/Melbourne.htm). Note, the script needs [Requests](http://docs.python-requests.org/en/latest/) to r…
"""
Where is my polling place?
==========================
Simple script to call the Google Geocoder service and get a map of polling
places. View the locations in Google Maps by converting the outout GeoJSON to
KML (Use ogr2ogr or `Jason Sanford's geojson-google-maps
<https://github.com/JasonSanford/geojson-google-maps>`_ utility) .Note that
the Google TOS require that the results of the geocode are used to be viewed
in google maps.
@om-henners
om-henners / mac_gis.sh
Created March 13, 2014 22:50
Shell scripts to install a reasonable base for GIS work on OS X 10.9 Mavericks
#!/bin/bash
#This script reinstalls my python/GIS environment on Maverics
#install homebrew
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew update
brew upgrade
#and now everything else
brew tap homebrew/dupes
@om-henners
om-henners / iPython_svg_example.ipynb
Last active August 29, 2015 13:58
iPython shapely geometry representation example
Loading
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 / script_mail_wrapper.py
Last active August 29, 2015 14:03
Example of using a with statement to wrap your script so that it will notify with an email on success or failure. The error is then re-raised, so whatever is running the original tool will see it. The mail section was taken from the snipped provided at http://gis.stackexchange.com/a/103394/150
import smtplib, os
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import traceback
import textwrap
from datetime import datetime
from StringIO import StringIO
@om-henners
om-henners / dennys laquinta distance.ipynb
Last active August 29, 2015 14:05
Found the [Mitch Hedberg and GIS](http://njgeo.org/2014/01/30/mitch-hedberg-and-gis/) article through [Hacker News](https://news.ycombinator.com/item?id=8191020) and decided to see just how much distance was needed for the statement to be true even in most case.
Loading
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 / minimum spanning tree.ipynb
Created October 30, 2014 01:41
minimum spanning tree and TSP
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
0 96.882
4.646 96.921
9.293 96.93
13.939 96.914
18.585 96.896
23.232 96.872
27.878 96.823
32.525 96.744
37.171 96.665
41.817 96.634
@om-henners
om-henners / fiona_streaming.py
Last active August 29, 2015 14:17
Tweepy streaming to Fiona
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Stream twitter data directly to a dataset with Fiona and Tweepy.
"""
import fiona
import fiona.crs
from tweepy.streaming import StreamListener
@om-henners
om-henners / Unsupervised imagery classification.ipynb
Created July 2, 2015 02:15
Example classifying raster imagery using scikit-learn for imagery classification
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.