Skip to content

Instantly share code, notes, and snippets.

View andy-esch's full-sized avatar
🌳

Andy Eschbacher andy-esch

🌳
View GitHub Profile
@andy-esch
andy-esch / columns.md
Created April 20, 2016 19:58
acs columns (extract)
  1. total_pop
  2. male_pop
  3. female_pop
  4. median_age
  5. white_pop
  6. black_pop
  7. asian_pop
  8. hispanic_pop
  9. amerindian_pop
  10. other_race_pop
@andy-esch
andy-esch / stddev_bins.sql
Created April 4, 2016 20:58
naive stddev bins script
CREATE OR REPLACE FUNCTION CDB_StdDevBins(input numeric[],
num_bins INT DEFAULT 5)
RETURNS NUMERIC[]
AS $$
DECLARE
mean_val numeric;
stddev_val numeric;
out_arr numeric[];
i int;
BEGIN
@andy-esch
andy-esch / README.md
Last active April 4, 2016 12:03
Stanford March 28 -- Intro Workshop

Intro to CartoDB

March 28, 2016

Follow along here: bit.ly/stanford-cartodb-march28

Intro

@andy-esch
andy-esch / README.md
Last active March 25, 2016 22:00
frick workshop
@andy-esch
andy-esch / README.md
Last active August 19, 2016 18:32
predicting trends in zillow data

This is an example of Spatial Markov analysis

@andy-esch
andy-esch / union_adjacent_polygons.sql
Created March 16, 2016 20:51
union adjacent polygons
CREATE OR REPLACE FUNCTION cdb_union_adjacent_test(table_name text)
RETURNS SETOF geometry As
$$
DECLARE
intersected_geoms geometry;
BEGIN
RETURN QUERY EXECUTE 'SELECT ST_Union(g) FROM (SELECT ST_ClusterIntersecting("the_geom") As g FROM ' || table_name || ') As x';
END
$$ LANGUAGE 'plpgsql';
@andy-esch
andy-esch / explain_cluster.sql
Created March 10, 2016 15:41
first (crude) pass at an explain_cluster function
-- first prototype to get summary information of a cluster
-- based on the geometries that originally made up the cluster
-- clusters are formed from spatially unioning adjacent geometries
CREATE OR REPLACE FUNCTION
explain_cluster(
clustered_geom_table text,
unclustered_geom_table text,
attrs text)
@andy-esch
andy-esch / README.md
Last active March 10, 2016 13:30
Outlier + Cluster blog post references

Researcher: Andy Eschbacher (@MrEPhysics)

Gen Z -- Outlier/Cluster

<iframe width="100%" height="520" frameborder="0" src="https://team.cartodb.com/u/eschbacher/viz/6ec87998-da36-11e5-bc31-0ea31932ec1d/embed_map" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>
@andy-esch
andy-esch / join_touching.sql
Last active February 23, 2016 13:22 — forked from stuartlynn/join_touching.sql
join_touching.sql
CREATE OR REPLACE FUNCTION final_merge_touching( joined_geoms geometry[] ) RETURNS geometry[] AS $$
BEGIN
return joined_geoms;
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION state_merge_touching(clusters geometry[], new_geom geometry) RETURNS geometry[] AS $$
DECLARE
joins geometry[] :='{}';
@andy-esch
andy-esch / index.html
Created February 10, 2016 19:55 — forked from stuartlynn/index.html
Color Picker
<!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>(function () {
function resolve() {
document.body.removeAttribute('unresolved');
}
if (window.WebComponents) {