Skip to content

Instantly share code, notes, and snippets.

View pnorman's full-sized avatar

Paul Norman pnorman

View GitHub Profile
@pnorman
pnorman / landsat.sh
Created January 5, 2014 06:10
fun with landsat
gdal_translate -ot Byte -a_nodata 0 -scale 5655 15725 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene24}_B4.TIF" "${scene24}_B4_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 5655 15725 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene25}_B4.TIF" "${scene25}_B4_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 5655 15725 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene26}_B4.TIF" "${scene26}_B4_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 6193 15287 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene24}_B3.TIF" "${scene24}_B3_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 6193 15287 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene25}_B3.TIF" "${scene25}_B3_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 6193 15287 1 255 -co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 "${scene26}_B3.TIF" "${scene26}_B3_strech.tif" &
gdal_translate -ot Byte -a_nodata 0 -scale 7105 15847 1
@pnorman
pnorman / disableheals.lua
Created February 20, 2014 11:50
from Semlar on IRC
local oCombatText_AddMessage = CombatText_AddMessage
CombatText_AddMessage = function(message, ...)
if not message:find('%[') then
oCombatText_AddMessage(message, ...)
end
end
@pnorman
pnorman / addresses.style
Last active August 29, 2015 13:56
address nodes near buildings of the same address but not inside
node,way addr:unit text polygon
node,way addr:housenumber text polygon
node,way addr:street text polygon
node,way addr:city text polygon
node,way building text polygon
node,way z_order int4 linear # This is calculated during import
way way_area real # This is calculated during import
@pnorman
pnorman / toast.md
Created March 5, 2014 09:24
toast query snippet

We can use a varient of the pg_class disk usage queries to find how much space is used by the toast tables for each of the rendering tables.

SELECT mains.relname, 
    toasts.relpages::bigint*8192 AS "toast size", toasts.reltuples AS "toast tuples", indexes.relpages::bigint*8192 AS "toast index size"
  FROM pg_class toasts
    JOIN pg_class mains ON (toasts.oid = mains.reltoastrelid)
    LEFT JOIN pg_class indexes ON (indexes.oid = toasts.reltoastidxid)
  WHERE 
 mains.relname IN ('planet_osm_point', 'planet_osm_line', 'planet_osm_polygon');
@pnorman
pnorman / amenity.style
Created March 7, 2014 19:34
.style file for osm2pgsql POIs only
# This osm2pgsql style file contains amenities, shops and other POIs
# See default.style for documentation on all the flags
# OsmType Tag Type Flags
node,way name text linear
node,way amenity text polygon
node,way leisure text polygon
node,way shop text polygon
@pnorman
pnorman / clc_cleanup.sql
Created March 23, 2014 01:21
SQL queries for finding CLC meadows for cleanup
CREATE TEMPORARY TABLE clc_ways AS SELECT id AS way_id,nodes
FROM ways w
LEFT JOIN relation_members rm ON (w.id = rm.member_id AND rm.member_type='W')
WHERE tags ? 'CLC:id'
AND tags @> hstore('landuse','meadow')
AND version=1
AND rm.relation_id IS NULL;
CREATE INDEX ON clc_ways (way_id) WITH (fillfactor=100);
ANALYZE clc_ways;
@pnorman
pnorman / active_contributors.sql
Created April 30, 2014 01:52
SQL to find active contributors as of 20140401
SELECT COUNT(*)
FROM (
SELECT user_name, COUNT(*) AS months
FROM (
SELECT DISTINCT user_name, date_trunc('month', created_at) as mon
FROM osm_changeset
WHERE num_changes > 0
AND created_at BETWEEN '20130401'::date AND '20140401'::date)
AS um GROUP BY user_name)
AS mon
@pnorman
pnorman / load.sh
Created May 9, 2014 17:50
Shell commands to set up and load OpenStreetMap data into a PostGIS database with osm2pgsql on Ubuntu 14.04 from scratch
sudo apt-get --no-install-recommends -y install software-properties-common
sudo add-apt-repository -y ppa:kakrueger/openstreetmap
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get --no-install-recommends -y install git unzip curl build-essential postgresql-9.3-postgis-2.1 postgresql-contrib-9.3 proj-bin libgeos-dev apache2 munin munin-node munin-plugins-extra libdbd-pg-perl sysstat iotop ptop osm2pgsql osmctools
sudo -u postgres createuser -s $USER
createdb gis
psql -d gis -c 'CREATE EXTENSION hstore; CREATE EXTENSION postgis;'
sudo munin-node-configure --sh | sudo sh
sudo service munin-node restart
sudo sed -i "s|Allow from.*|Allow from all|" /etc/munin/apache.conf
#placenames-medium {
[capital = 'yes'] {
[zoom >= 5][zoom < 15] {
text-name: "[name]";
text-size: 10;
text-fill: @placenames;
text-face-name: @book-fonts;
text-halo-radius: 1.5;
text-min-distance: 10;
[zoom >= 6] {
@pnorman
pnorman / index.html
Last active August 29, 2015 14:01 — forked from tyrasd/index.html
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>