Skip to content

Instantly share code, notes, and snippets.

@walkermatt
walkermatt / script.js
Created July 5, 2012 19:00 — forked from nextstopsun/script.js
Proj4Leaflet 102012 projection test
var res = [
140000.0000000000,
70000.0000000000,
35000.0000000000,
17500.0000000000,
8750.0000000000,
4375.0000000000,
2187.5000000000,
1093.7500000000,
546.8750000000,
@walkermatt
walkermatt / prep_policekml.py
Created July 29, 2012 20:44
Simple Loader prep class to import KML police.uk neighbourhood boundaries
"""
A class used to manipulate Police KML data, used with prepgml4ogr.py.
"""
import os
from lxml import etree
class prep_kml():
def __init__(self, inputfile):
@walkermatt
walkermatt / mario.clj
Created October 17, 2015 19:08
Mario style pyramids!
; Inspired by
; http://entxtech.blogspot.co.uk/2015/10/how-to-write-more-functional-and.html
; "create a program where you can enter a height in blocks for a mario-like
; pyramid (like the one Mario runs up to reach the flag-pole). Once the height
; is specified, you then build the pyramid using hashes and spaces."
; ## [0,2]
; ## [1,2]
; ### [0,3]
@walkermatt
walkermatt / run_loader.bat
Last active December 10, 2015 21:08
DOS batch file to run Loader (https://github.com/AstunTechnology/Loader) on Windows using GDAL and python provided by OSGeo4W (installation of which is documented on the wiki)
rem DOS batch file to run Loader on Windows using GDAL and python
rem provided by OSGeo4W. As this script requires the OSGeo4W environment
rem to run it must be passed as an argument to OSGeo4W.bat like so:
rem call C:\OSGeo4W\OSGeo4W.bat C:\Temp\Loader\run_loader.bat
rem Change to the folder that this script is in (assumes this script is
rem in the same folder as the Loader readme)
cd /D %~dp0
rem change to the python directory
@walkermatt
walkermatt / Gazetteer.vrt
Created February 6, 2013 08:11
Example AstunTechnology / OpenDataLoader (https://github.com/AstunTechnology/OpenDataLoader) config for OS 50k Gazetteer. OSOpenLoader.config and Table.csv should live in the root of the OpenDataLoader directory. Gazetteer.vrt should go in the source Gazetteer directory.
<OGRVRTDataSource>
<OGRVRTLayer name="50kgaz2012_new">
<SrcDataSource>/home/matt/Downloads/gaz50k_gb/Gazetteer/50kgaz2012_new.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>EPSG:27700</LayerSRS>
<GeometryField encoding="PointFromColumns" x="EAST" y="NORTH"/>
</OGRVRTLayer>
</OGRVRTDataSource>
@walkermatt
walkermatt / content.ftl
Last active December 25, 2015 22:49
GeoServer Freemarker template
<ul>
<#list features as feature>
<li><h2>${feature.type.title}</h2>
<ul>
<#list feature.attributes as attribute>
<#if !attribute.isGeometry>
<li>${attribute.name?replace("_", " ", "i")?cap_first}:
<#if attribute.value?starts_with('http')>
<a href="${attribute.value}">${attribute.value}</a>
<#else>
@walkermatt
walkermatt / astun.py
Created November 13, 2013 19:52
Example of configuring Astun Tech QGIS-Gazetteer-Plugin (https://github.com/AstunTechnology/QGIS-Gazetteer-Plugin) to use a specific iShare location search (Surrey Heath Borough Council in this instance).
from json import loads
from collections import namedtuple
url = "http://isharemaps.surreyheath.gov.uk/getdata.aspx"
params = {
'type': 'json',
'RequestType': 'LocationSearch',
'gettotals': 'true',
'axuid': '1344265603167',
'mapsource': 'SurreyHeath/AllMaps',
@walkermatt
walkermatt / a.gml
Created November 26, 2013 09:40
Test case to reproduce ogr2ogr error loading feature types with no geometry into PostgreSQL 9.1 / PostGIS 1.5. Sample data has been munged to avoid copyright issues.
<?xml version="1.0"?>
<FeatureCollection osgb="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb" gml="http://www.opengis.net/gml" fid="GDS-1389940-6811" xsi="http://www.w3.org/2001/XMLSchema-instance" xlink="http://www.w3.org/1999/xlink" schemaLocation="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb http://www.ordnancesurvey.co.uk/xml/schema/v7/OSDNFFeatures.xsd">
<description>Ordnance Survey, (c) Crown Copyright. All rights reserved, 2013-10-28</description>
<roadMember>
<Road fid="osgbfoo">
<version>5</version>
<versionDate>2006-02-06</versionDate>
<theme>Road Network</theme>
<changeHistory>
<changeDate>2003-03-13</changeDate>
@walkermatt
walkermatt / spatialtype.md
Created June 22, 2015 11:02
mapinfo.mapinfo_mapcatalog spatialtype values for PostGIS

MapInfo requires a mapinfo.mapinfo_mapcatalog relation to be present in a PostGIS database in order to load relations. The spatialtype column is a float which indicates the geometry type of the relation:

19.0 = POINT, MULTIPOINT
19.1 = LINESTRING, MULTILINESTRING
19.2 = POLYGON, MULTIPOLYGON
19.3 = GEOMETRY
@walkermatt
walkermatt / Rock, paper, scissors.py
Created December 17, 2016 09:21
Rock, paper, scissors created by walkermatt - https://repl.it/EsHd/15
# Rock, paper, scissors
def beats(thing1, thing2):
""" Determine who wins rock, paper, scissors
by passing each players choice """
if thing1 == thing2:
# Draw, both players chose the same thing
return None
# Determine which thing beats thing2
victors = {