Skip to content

Instantly share code, notes, and snippets.

View nvkelso's full-sized avatar

Nathaniel V. KELSO nvkelso

View GitHub Profile
@nvkelso
nvkelso / countTiles.py
Created March 1, 2012 22:04 — forked from andrewharvey/countTiles.py
Given a WGS84 bounding box and an OSM tile zoom range calculates a total number of tiles and how much the Amazon Cloud will cost ya.
#!/usr/bin/python
# README
#
# This script is from: https://gist.github.com/1953554
# By Nathaniel Vaughn Kelso and Mike Migurski @ Stamen
#
# Based on script by andrewharvey: https://gist.github.com/1675606
#
# This script should be considered CC0 licensed
@nvkelso
nvkelso / ModestMaps.js
Created March 6, 2012 00:49
Use Stamen's map tiles in your favorite mapping library, ModestMaps version
// replace "toner" here with "terrain" or "watercolor"
var layer = new MM.StamenTileLayer("toner");
var map = new MM.Map("element_id", layer);
map.setCenterZoom(new MM.Location(37.7, -122.4), 12);
@nvkelso
nvkelso / Leaflet.js
Created March 6, 2012 00:51
Use Stamen's map tiles in your favorite mapping library, Leaflet version
// replace "toner" here with "terrain" or "watercolor"
var layer = new L.StamenTileLayer("toner");
var map = new L.Map("element_id", {
center: new L.LatLng(37.7, -122.4),
zoom: 12
});
map.addLayer(layer);
@nvkelso
nvkelso / OpenLayers.js
Created March 6, 2012 00:52
Use Stamen's map tiles in your favorite mapping library, OpenLayers version
// replace "toner" here with "terrain" or "watercolor"
var layer = new OpenLayers.Layer.Stamen("toner");
var map = new OpenLayers.Map("element_id");
map.addLayer(layer);
@nvkelso
nvkelso / GoogleMaps.js
Created March 6, 2012 00:52
Use Stamen's map tiles in your favorite mapping library, Google Maps version
// replace "toner" here with "terrain" or "watercolor"
var layer = "toner";
var map = new google.maps.Map(document.getElementById("element_id"), {
center: new google.maps.LatLng(37.7, -122.4),
zoom: 12,
mapTypeId: layer,
mapTypeControlOptions: {
mapTypeIds: [layer]
}
});
@nvkelso
nvkelso / fieldpapers-bookmarklet.js
Created April 20, 2012 00:26 — forked from mapmeld/fieldpapers-bookmarklet.js
FieldPapers: experimental marker editor and tile inspector via bookmarklet
/*
Turns red dots on the Field Papers tiles into markers automatically
Write a description to save the marker
I don't understand the server-side installation or the QR-scanning, so I'm using a bookmarklet
Client-side HTML5 Canvas for tile inspection
*/
// collect the most zoomed-in tiles from the scan
var zoomimgs = document.getElementsByTagName("img");
var maxzoom = 0;
legend: #PctHomesInNegEquityOfMortgage
<span style="color: #e73a43">▉</span> 0.4 – 1.0 <br />
<span style="color: #ff7265">▉</span> 0.3 – 0.4 <br />
<span style="color: #ffac8f">▉</span> 0.2 – 0.3 <br />
<span style="color: #ffd8b0">▉</span> 0.1 – 0.2 <br />
<span style="color: #fff4e5">▉</span> 0.0 – 0.1 <br />
<span style="color: #cad8e5">▉</span> No data
@nvkelso
nvkelso / true-distance-to-shore.py
Created May 30, 2012 22:02 — forked from scw/true-distance-to-shore.py
Example using OGR and Shapely to compute true distances between geometries and points.
#!/usr/bin/env python
# distance_from_shore.py: compute true distance between points
# and closest geometry.
# shaun walbridge, 2012.05.15
# TODO: no indexing used currently, could stand if performance needs
# improving (currently runs in ~1.5hr for 13k points)
from geopy import distance
@nvkelso
nvkelso / ne_1d4_utf8_web_merc_900913
Created June 5, 2012 23:33
Natural Earth 1.4 UTF-8 + spherical mercator ZIPS
UTF-8 + spherical mercator.
http://cascadenik.teczno.com/data/ne-1.4/900913/admin_0_boundary_breakaway_disputed_areas_10m.zip
http://cascadenik.teczno.com/data/ne-1.4/900913/admin_0_boundary_breakaway_disputed_areas_50m.zip
http://cascadenik.teczno.com/data/ne-1.4/900913/admin_0_boundary_lines_land_10m.zip
http://cascadenik.teczno.com/data/ne-1.4/900913/admin_0_boundary_lines_land_50m.zip
http://cascadenik.teczno.com/data/ne-1.4/900913/admin_0_boundary_lines_land_110m.zip
http://cascadenik.teczno.com/data/ne-1.4/900913/admin_0_boundary_lines_map_units_10m.zip
http://cascadenik.teczno.com/data/ne-1.4/900913/admin_0_boundary_lines_maritime_indicator_10m.zip
http://cascadenik.teczno.com/data/ne-1.4/900913/admin_0_boundary_lines_maritime_indicator_50m.zip
@nvkelso
nvkelso / gist:2898674
Created June 8, 2012 23:29
sqlite db for natural earth
zips/packages/natural_earth_vector.sqlite.zip:
#SQL-Lite
for shp in 10m_cultural/*.shp 10m_physical/*.shp 50m_cultural/*.shp 50m_physical/*.shp 110m_cultural/*.shp 110m_physical/*.shp; \
do \
ogr2ogr -f SQLite -append zips/packages/natural_earth_vector.sqlite $$shp; \
done
zip zips/packages/natural_earth_vector.sqlite.zip zips/packages/natural_earth_vector.sqlite VERSION README.md CHANGELOG