Skip to content

Instantly share code, notes, and snippets.

@strk
strk / index.html
Last active August 29, 2015 13:56 — forked from andrewxhill/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--Edit the title of the page-->
<title>CartoDB Point Clustering</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CartoDB Point Clustering</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
<!--[if lte IE 8]>
@strk
strk / kmeans.sql
Created December 4, 2012 08:31 — forked from andrewxhill/kmeans.sql
kmeans function and examples
--DROP FUNCTION axh_kmeans_geom_sort(geometry[], integer, integer);
CREATE OR REPLACE FUNCTION axh_kmeans_geom_sort(the_geom geometry[], clusters integer DEFAULT NULL, iterations integer DEFAULT NULL)
RETURNS SETOF GEOMETRY
AS $$
DECLARE
h GEOMETRY; -- rectangle cell
c INTEGER; --
@strk
strk / kmeans.sql
Created December 3, 2012 08:26 — forked from andrewxhill/kmeans.sql
kmeans function and examples
--DROP FUNCTION axh_kmeans_geom_sort(geometry[], integer, integer);
CREATE OR REPLACE FUNCTION axh_kmeans_geom_sort(the_geom geometry[], clusters integer DEFAULT NULL, iterations integer DEFAULT NULL)
RETURNS SETOF GEOMETRY
AS $$
DECLARE
h GEOMETRY; -- rectangle cell
c INTEGER; --
@strk
strk / query.sql
Created September 4, 2012 11:10 — forked from javisantana/query.sql
grid postgis query
WITH
hgrid AS (
SELECT CDB_HexagonGrid(
ST_Transform(ST_MakeEnvelope(-180, -89, 180, 89, 4326), 3857), -- extent of the grid
CDB_XYZ_Resolution({z}) * 15 -- size of each cell
) as cell
)
SELECT count(i.<%=prop%>) as points_count