Skip to content

Instantly share code, notes, and snippets.

@ian29
ian29 / gist:1264435
Created October 5, 2011 13:34
Puerto Rico Interactivity
function(options, data) { switch (options.format) { case 'full': return ''; break; case 'location': return ''; break; case 'teaser': default: return '<div class="census-int"><div class="int-title">' + data.namelsad10 + '</div><div class="int-subtitle">Change from 2000-2010</div><div class="pop-int">Population: <span class="popnum-int">' + data.total_pop_2010 + '</span><span class="poppct-int">' + data.total_pop_chg_c + '%</span></div><div class="regavg-int">Regional Average: <span class="regnum-int">+10.85%</span></div><div class="natavg-int">National Average: <span class="natnum-int">+9.77%</span></div><div class="chart-int"><img src="http://chart.apis.google.com/chart?chf=bg,s,FFFFFF00&chxl=0:|Non-Hispanic|Hispanic|+|2+or+More|White|Other|Hawaii/Oth+Pacific|Black|Asian|Am+Indian/Alaskan|1:|0|20|40|60|80|100|&chbh=6,0,8&chxr=1,0,120,20&chxs=0,252525,10,1,l,252525|1,3A3A3A,10,0,l,3A3A3A&chxt=y,x&chs=280x240&cht=bhg&chco=969696,3A3A3A&chds=0,120,0,120&chlp=b&chd=t
@ian29
ian29 / all layers.js
Created October 5, 2011 18:21
puertorico interactivity
function(options, data) { switch (options.format) { case 'full': return ''; break; case 'location': return ''; break; case 'teaser': default: return '<div class="census-int"><div class="int-title">' + data.namelsad10 + '</div><div class="pop-int">Population: ' + data.pop2010 + '</div><div class="chg-int">Change from 2000-2010: <span class="poppct-int">' + data.usat36_pct + '%</span></div><div class="regavg-int">Regional Average: <span class="regnum-int">+10.85%</span></div><div class="natavg-int">National Average: <span class="natnum-int">+9.77%</span></div><div class="chart-int"><img src="http://chart.apis.google.com/chart?chf=bg,s,FFFFFF00&chxl=0:|Non-Hispanic|Hispanic|+|2+or+More|White|Other|Hawaii/Oth+Pacific|Black|Asian|Am+Indian/Alaskan|1:|0|20|40|60|80|100|||2:|||||||Change|&chbh=6,0,8&chxr=1,0,140&chxs=0,252525,10,1,l,252525|1,3A3A3A,10,0,l,3A3A3A|2,3A3A3A,10,0,l,3A3A3A&chxt=y,x,t&chs=280x250&cht=bhg&chco=969696,3A3A3A&chds=0,1.4,0,1.4&chlp=b&chd=t:' + da
<style type="text/css">
.wax-legend {
padding-top: 5px;
overflow: hidden;
min-width: 250px;
}
.wax-legend .ws-title {
text-align: center;
@ian29
ian29 / Change in ag yields legend
Created November 14, 2011 16:10
Change in ag yields legend
<style type="text/css">
.wax-legend {
max-width: 600px;
}
.wax-legend .y-legend {
padding-top: 5px;
max-width: 500px;
width: 230px;
<style type='text/css'>
.wax-legend {
font-size:12px;
max-width:275px;
width: 275px;
}
.wax-legend .wbpj-title {
text-align: center;
padding-bottom:10px;
border-bottom:1px solid #c5c5c7;
@1: #DEB147;
@2: #D68A5A;
@3: #D5796B;
@4: #BE6291;
@5: #93639E;
@nodata:#a4abaf;
#tmsch1 {
::data {
[all_gradrate09 < .6][all_gradrate09 > 0]{marker-fill: @2;}
CREATE TABLE clean_lea AS
SELECT
nt.*,
c.stnam stnam07,
c.fipst fipst07,
c.leanm07,
c.leaid leaid07,
cast(round((all_math04pctprof_0708 * 100), 1) as text)||'%' all_math04_0708,
cast(round((all_math08pctprof_0708 * 100), 1) as text)||'%' all_math08_0708,
cast(round((all_math12pctprof_0708 * 100), 1) as text)||'%' all_math12_0708,
update clean_sch set all_read04_0910 = 'n/a' where all_read04_0910 = '0.0%';
update clean_sch set all_read08_0910 = 'n/a' where all_read08_0910 = '0.0%';
update clean_sch set all_read10_0910 = 'n/a' where all_read10_0910 = '0.0%';
update clean_sch set all_read12_0910 = 'n/a' where all_read12_0910 = '0.0%';
update clean_sch set all_read04_0809 = 'n/a' where all_read04_0809 = '0.0%';
update clean_sch set all_read08_0809 = 'n/a' where all_read08_0809 = '0.0%';
update clean_sch set all_read10_0809 = 'n/a' where all_read10_0809 = '0.0%';
update clean_sch set all_read12_0809 = 'n/a' where all_read12_0809 = '0.0%';
update clean_sch set all_read04_0708 = 'n/a' where all_read04_0708 = '0.0%';
update clean_sch set all_read08_0708 = 'n/a' where all_read08_0708 = '0.0%';

Converting to SQLite

Importing the spatially-explicit tables (TMsch.csv and TMlea.csv, in the form of simple lat/long coordinates) into QGIS via the'Add Delimited Text Layer' plugin, allows for a first look at the data. Selecting 'Save layer as vector file..' from the Layers menu. In the dialog box, select the following parameters:

Format: SQLite
Encoding: UTF-8
CRS: Google Mercator EPSG:900913

Import the non-spatial .csv tables into SQLite database files using a database inspector like Base or from the command line using SQL for SQLite. Be sure to import all six tables into one database.

<style>
.wax-tooltip {
font: 13px/20px 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: #404040;
height: auto;
background: #fff;
border: 1px solid #8C8C8C;
border: 1px solid rgba(0, 0, 0, .45);
-moz-box-shadow: 0 1px 8px rgba(0, 0, 0, .3);
-webkit-box-shadow: 0 1px 8px rgba(0, 0, 0, .3);