Skip to content

Instantly share code, notes, and snippets.

@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
ERROR: Error running python shp_normalizer script: /usr/bin/python -Wignore /home/src/cartodb/cartodb/lib/importer/misc/shp_normalizer.py "/tmp/20120314-24180-kf8q8i.com2011.shp" importing_1331741285_com2011
ERROR:
ERROR: Error running python shp_normalizer script: /usr/bin/python -Wignore /home/src/cartodb/cartodb/lib/importer/misc/shp_normalizer.py "/tmp/20120314-24180-kf8q8i.com2011.shp" importing_1331741285_com2011
ERROR: Table error, #<RuntimeError: Error running python shp_normalizer script: /usr/bin/python -Wignore /home/src/cartodb/cartodb/lib/importer/misc/shp_normalizer.py "/tmp/20120314-24180-kf8q8i.com2011.shp" importing_1331741285_com2011>
', "updated_at" = '2012-03-14 17:08:04.571844+0100', "created_at" = '2012-03-13 17:48:10.934778+0100' WHERE ("id" = 1)