Skip to content

Instantly share code, notes, and snippets.

View DanielJWood's full-sized avatar

Daniel Wood DanielJWood

View GitHub Profile
@DanielJWood
DanielJWood / gist:1705208
Created January 30, 2012 16:14
attaching db in sql
Attach Database '/Users/danielwood/Dropbox/geodata-prep/sqlite-databases-new/ACS_06_VAP.sqlite' AS ACS_06_VAP;
SELECT * FROM ASN
join ACS_06_VAP.COUNTY on ASN.geoid = COUNTY.geoid;
@DanielJWood
DanielJWood / DMAdocumentation.md
Created March 16, 2012 23:18
Creating DMA polygons
  1. Get your DMA data into an sqlite file. This sqlite file must contain the county FIPS, the name of the DMA area, and the unique DMA code for that area.
  2. Create a county sqlite file from a county shapefile that contains county FIPS.
  3. Join DMA sqlite with a geographic enabled county polygon sqlite file to create a DMA sqlite file that has a geometry column.
  4. Load the DMA sqlite file into Qgis
  5. Use the dissolve tool to create the larger dma shapes from the smaller counties (Vector>Geoprocessing Tools>Dissolve)
  • The Input vector layer is the DMA sqlite file
  • The Dissolve Field is whatever unique ID each DMA has. So all the counties surrounding around Mobile Alabama and Pensacola Florida, for instance, would use the dissolve field that containedMobile, AL-Pensacola, FL.
  1. View your new DMA polygons, and save as an sqlite file, in whatever projection you need it in.

Troubleshooting:

@DanielJWood
DanielJWood / collegeblogpost.md
Created April 12, 2012 20:11
College Blog Post

Putting Colleges on the Map

MapBox's OSM Sprint comes to a Campus near you

In recent weeks, the MapBox team has participated in a mapping sprint to improve areas of the world that lack coverage in OpenSteetMap. Since starting our mapping sprint, we have traced streets, buildings and parks in highly populated, under-mapped areas of the world like Mexico, Brazil, Bangkok and drought stricken West Africa

Our first major mapping push in the US has been to add building footprints to college campuses in OpenStreetMap. We prioritized building footprints because that's the place where students check in the most on Foursquare, which now uses MapBox Streets. But where to find colleges that need tracing? We figured we should find to schools where students' spend more

@DanielJWood
DanielJWood / UNOCHA-Documentation.md
Created April 18, 2012 20:58
UNOCHA data Processing notes

The UNOCHA data was mined from the UNOCHA website and saved locally as zipped Shp files. The following steps were taken for processing all admin and populated places files from raw data into tilemill.

  1. Unzip Shapefile
  2. Load into QGIS and save three versions of the file in different projections and file types; SQlite with WGS 84, Shapefile with WGS 84, and SQlite file Google Mercator. The first two are for data download purposes. The last one is for use in Tilemill.
  • Note: You can also reproject these files by using tools like the ogr2ogr tool in GDAL, but I decided that it was easier to view and save the data through a UI like QGIS.
  • Note: Not all files are named well in their raw forms. In general, admin 1 means the largest boundaries subnational boundaries, admin 2 means the next largest subnational boundaries, and so on.

For the following files, additional joins have to be made to create the final file:

Chad Population at the Admin 2 le

@DanielJWood
DanielJWood / app.js
Created April 24, 2012 21:27
Crime map javascript
var map, interaction;
var mm = com.modestmaps;
var layer = 'danwood.crime10hex';
var urlBase ='http://api.tiles.mapbox.com/v3/mapbox.mapbox-light,';
var url = urlBase + layer + '.jsonp';
wax.tilejson (url, function(tilejson) {
tilejson.minzoom = 1;
tilejson.maxzoom = 16;
@DanielJWood
DanielJWood / omsdevlog.md
Created April 27, 2012 14:29
OSM sprint devlog

Over the last two months, the OSM data sprint has turned into the OSM data 5K and we've gotten some pretty awesome stuff accomplished. I'd like to supply some relevant links and talk a little bit about what we've accomplished and learned these last two months.

A long time ago in a galaxy far far away.... border tagging

Our major focus on OSM data quality stems from the use of OSM in MapBox Streets. In the early days of MB Streets we noticed major national and subnational boundaries missing from MB Streets at certain zoom levels. In OSM the borders are tagged inconsistently so it makes rendering them in tilemill a bit difficult. We tried to standardize this by adding appropriate boundary and admin level tags to areas where the boundaries existed but were tagged wrong.

We used Ian's map to identify places where there were missing boundaries in MB streets (yellow boundaries without green boundaries for subnational, purple without black for national).

@DanielJWood
DanielJWood / widget.js
Created July 2, 2012 19:46
Change in twitter widget
// twitter
new TWTR.Widget({
version: 2,
type: 'search',
search: '#ICC OR #demandjustice',
//The above was changed from 'amnesty' to '#ICC OR demandjustice'
interval: 30000,
title: 'Amnesty Tweets',
subject: '',
width: 250,
@DanielJWood
DanielJWood / cobaltapp.js
Last active December 13, 2015 22:59
javascript from https://github.com/DanielJWood/cobalt . see other files there.
//COULD CREATE THIS ARRAY WITH A FOR LOOP PULLING FROM THE INDEX
// TRASH! var breakdown = [{"DR":[]},{"DI":[]},{"MP":[]},{"LT":[]},{"DA":[]},{"FD":[]}]
var markers = [];
//build map elements
var map = mapbox.map('map');
map.addLayer(mapbox.layer().id('grassroots.map-lv8enaf8'));
map.addLayer(mapbox.layer().id('grassroots.africa-protraction'));
map.ui.zoomer.add();
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":["-82.821443","34.358034"]},"properties":{"Name":"Hartwell Dam","Initial Year":"1962","Generating Units":"5","Average Energy":"486,000 MWH","System Name":"GA-AL-SC"}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-82.594035","34.02549"]},"properties":{"Name":"Richard B. Russell Dam","Initial Year":"1985","Generating Units":"8 (4 Turbine)","Average Energy":"756,000 MWH","System Name":"GA-AL-SC"}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-82.199761","33.661175"]},"properties":{"Name":"J. Strom Thurmond Dam","Initial Year":"1953","Generating Units":"7","Average Energy":"731,000 MWH","System Name":"GA-AL-SC"}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-84.67015","34.613714"]},"properties":{"Name":"Carters Dam","Initial Year":"1975","Generating Units":"4 (2 Turbine)","Average Energy":"398,000 MWH","System Name":"GA-AL-SC"}},{"type":"Feature","geometry":{"type":"Po
@DanielJWood
DanielJWood / index.html
Created October 18, 2013 20:42
Working Disable Zooming and Panning example for Mapbox js
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title></title>
<script src='http://api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.css' rel='stylesheet' />
<!--[if lte IE 8]>
<link href='//api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.ie.css' rel='stylesheet'>
<![endif]-->