This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Extract route relations from osm2pgsql-generated database to CSV. | |
''' | |
from sys import argv | |
from csv import writer | |
from psycopg2 import connect | |
if __name__ == '__main__': | |
db = connect(database='raster_osm', user='osm').cursor() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
ogr2ogr -overwrite -t_srs '+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs' PG:"user=nhd dbname=nhd" NHDFlowline.shp | |
create table nhdflowline_snapped ( ogc_fid integer primary key ); | |
select addgeometrycolumn('', 'nhdflowline_snapped', 'geometry', 900914, 'LINESTRING', 2); | |
create index nhdflowline_snapped_geom_idx on nhdflowline_snapped using gist (geometry); | |
insert into nhdflowline_snapped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
#!/bin/sh -x | |
apt-get -y update | |
apt-get -y install htop osmosis git python-pip python-shapely python-pyproj python-networkx qhull-bin | |
git clone git://github.com/migurski/Skeletron.git ~/Skeletron | |
cd ~/Skeletron | |
python setup.py install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Sample datasource for remote tiled data in Mapnik. | |
See also https://github.com/mapnik/mapnik/wiki/Python-Plugin | |
Use in Mapnik: | |
<Datasource> | |
<Parameter name="type">python</Parameter> | |
<Parameter name="factory">RemoteGeoJSON:Datasource</Parameter> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
from multiprocessing import Pool | |
from numpy import zeros, ubyte | |
from psycopg2 import connect | |
from osgeo import gdal, osr | |
from PIL import Image | |
def measure_quad(x, y, cellsize): | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' Convert binary data to UTF8. | |
If you want binary data in Javascript over XMLHttpRequest but don't | |
have ArrayBuffer available, one option is to read strings of text and | |
use xhr.responseText.charCodeAt() to read them. Because this expects to | |
work with text, it will return the unicode of the character at that | |
position. This script converts raw binary bytes to unicode text that | |
evaluates to the same 8-bit unsigned int at each position. The overall | |
length will increase slightly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
radius = 20037508.343 | |
mins = [2 * radius * n/8. - radius for n in range(0, 8)] | |
maxs = [2 * radius * n/8. - radius for n in range(1, 9)] | |
edges = zip(mins, maxs) | |
for (index, ((xmin, xmax), (ymin, ymax))) in enumerate(product(edges, edges)): | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Joinery</title> | |
<script src="http://d3js.org/d3.v3.min.js" type="application/javascript"></script> | |
<style title="text/css"> | |
<!-- | |
div { margin: 5px; padding: 5px 10px; color: white; float: left } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import stderr | |
from osgeo import ogr | |
from time import time | |
from math import sqrt | |
def not_big(feature): | |
highway = feature.GetFieldAsString(feature.GetFieldIndex('type')) | |
return highway in ('residential', 'unclassified', 'road', 'minor') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var require = function (file, cwd) { | |
var resolved = require.resolve(file, cwd || '/'); | |
var mod = require.modules[resolved]; | |
if (!mod) throw new Error( | |
'Failed to resolve module ' + file + ', tried ' + resolved | |
); | |
var cached = require.cache[resolved]; | |
var res = cached? cached.exports : mod(); | |
return res; | |
}; |