Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css">
html, body {height: 100%; padding: 0; margin: 0;}
#map {position:absolute; width:100%; top:0; right:0; bottom:0; left:0;}
</style>
<link href="http://staging20.cartodb.com/assets/leaflet-510ae051a5d99e48b066cfdc9b22c20b.css" media="screen" rel="stylesheet" type="text/css" />
<link href="http://staging20.cartodb.com/assets/cdb/themes/css/cartodb-3836c012509ff34e44900ab95393c88f.css" media="screen" rel="stylesheet" type="text/css" />
@jatorre
jatorre / gist:4154502
Created November 27, 2012 14:28
Combine multiple Census files into single shpefile using PostGIS
mkdir tmpfolder;
cd tmpfolder;
wget "http://www2.census.gov/geo/tiger/TIGER2012/TRACT/tl_2012_01_tract.zip";
unzip tl_2012_01_tract.zip;
shp2pgsql -s4326 -p tl_2012_01_tract.shp census | psql -hlocalhost -Upostgres -dcensus;
rm -rf tl_2012_01_tract.*;
for i in {1..9} :;
do
wget "http://www2.census.gov/geo/tiger/TIGER2012/TRACT/tl_2012_0${i}_tract.zip";
unzip tl_2012_0${i}_tract.zip
/** bubble visualization */
#tm{
marker-fill: #FF5C00;
marker-line-color: #FFF;
marker-line-width: 2;
marker-line-opacity: 1;
marker-opacity: 0.8;
marker-placement: point;
marker-type: ellipse;
@jatorre
jatorre / robot.js
Created December 6, 2012 09:33
kkmucha
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
@jatorre
jatorre / robot.js
Created December 6, 2012 09:36 — forked from eterror/robot.js
Zolmeister
//FightCode can only understand your robot
//if its class is called Robot
var go=120;
var Robot = function(robot) {
};
-- Create a function withn the security set to Definer so that it can insert
CREATE OR REPLACE FUNCTION cdb_insert_point(float, float) RETURNS integer
AS 'INSERT INTO example_table(the_geom) VALUES(ST_SetSRID(ST_MakePoint($1,$2),4326)) RETURNING cartodb_id;'
LANGUAGE SQL
SECURITY DEFINER
RETURNS NULL ON NULL INPUT;
--Grant access to the public user
GRANT EXECUTE ON FUNCTION cdb_insert_point(float,float) TO publicuser;
http://viz2.cartodb.com/api/v2/sql?api_key=XXXXXXX&q=
-- Example SQL to create a table named new_table. Replace new_table with whatever name you want
CREATE TABLE new_table
(
--Data types we recommend using: text, integer, float(8), boolean, timestamp without time zone
barrio text,
perimetro numeric,
area numeric,
comuna integer,
@jatorre
jatorre / README.md
Last active December 11, 2015 22:48 — forked from friedbunny/README.md

Mouseover streets in this D3.js-driven visualization that allows users to visualize the citywide extent of a given street. The City of Philadelphia Streets Department maintains and distributes geospatial data representing and describing the city's street network. The data along with more information is availabe at Open Data Philly. Street location and name data is stored in a CartoDB table. A merge by attribute operation, street name in this case, achieved improvements over the previous file size that approached 3MB.

Download size can be further reduced by using PostGIS functions ST_Simplify or ST_SimplifyPreserveTopology. Without loss of det

http://simonrogers.cartodb.com/tables/meteoritessize/embed_map?title=false&description=true&search=true&shareable=true&cartodb_logo=true&sql=&zoom=2&center_lat=15.633333&center_lon=32.533333?fb=native&commentpage=1
@jatorre
jatorre / gist:5514912
Created May 3, 2013 22:57
Example of a Google Spcripting language program to insert data from a Google Form, georeference it and insert it on CartoDB.
function onFormSubmission(e) {
//Georeference the submission
var loc = geocode(e.namedValues.location);
postToCartoDB(
e.namedValues.location,
e.namedValues.sport,
loc.lat,
loc.lng