Skip to content

Instantly share code, notes, and snippets.

View demiurg's full-sized avatar

Pavel demiurg

View GitHub Profile
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
# Example of using Fiona, pyproj, and Shapely together in a functional
# style.
import functools
import itertools
import logging
import sys
import fiona
from pyproj import Proj, transform
g++ -o ./generate_tile test/generate_tile.cpp src/vector_tile.pb.cc -I./src -I/usr/include -I/usr/include/mapnik/agg -I/usr/include -I/usr/include/freetype2 -I/usr/include/libxml2 -I/usr/include/gdal -I/usr/include/postgresql -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng12 -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ4 -DHAVE_PNG -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -DSHAPE_MEMORY_MAPPED_FILE -DHAVE_LIBXML2 -g -O3 -Wall -pthread -ftemplate-depth-300 -O3 -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts -Wsign-compare -pthread -L/usr/lib -lmapnik -L/usr/lib -L/usr/lib/x86_64-linux-gnu -lfreetype -licuuc -lboost_filesystem -lboost_system -lboost_regex -lproj -lpng -ltiff -ljpeg -lxml2 -lz -lboost_thread -licui18n -ldl -lcairo -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ4 -DHAVE_PNG -DHAVE_TIFF -DLINUX -DMAPNI
import os
from os.path import *
import shutil
brewdirs = set()
for r, d, files in os.walk('/usr/local/lib'):
for n in files:
f = join(r,n)
if islink(f) and "/Cellar/" in realpath(f):
dirs = f.split('/')
@demiurg
demiurg / clustering.py
Last active August 29, 2015 14:01
simple clusters
#FOR DBSCAN
from sklearn.cluster import DBSCAN
from sklearn import metrics
from sklearn.datasets.samples_generator import make_blobs
from sklearn.preprocessing import StandardScaler
from random import randrange
import math
from numpy import array, argwhere
#For Kmeans
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"flake8": {
WITH empty AS(
SELECT ST_MakeEmptyRaster(256, 256, -5205055.878107, 7905423.213366, 9783.939620) as alignto
) SELECT ST_AsGDALRaster(
ST_Transform(ma3, alignto), 'PNG'
) as tiffvals,
FROM (
SELECT ST_MapAlgebra(
isUnion,
ma2,
'(CASE WHEN [rast1] <= 10 and [rast2] = 101 THEN 101 ELSE 100 END::int)'
#!/usr/bin/env python
import fiona
import csv
shp = fiona.open("TOWNSSURVEY_PT.shp")
print "Columns: {}".format(shp.schema['properties'].keys())
prop_csv = csv.DictWriter(open("props.csv", 'wb'), shp.schema['properties'].keys())
--- update fcpf_subnat_cea set geom_simple = st_simplify(st_buffer(st_buffer(st_simplify(wkb_geometry, 200), 200), -200), 2000) where hasc_1 = 'CL.MA';
--- update fcpf_subnat_cea set geom_simple = ST_MULTI(st_buffer(st_simplify(st_buffer(st_buffer(wkb_geometry, 500), -500), 2000), 0)) where not st_isvalid(geom_simple);
--- select hasc_1, uniquename, BIT_LENGTH(geom_simple::bytea)::int, st_isvalid(geom_simple) from fcpf_subnat_cea order by bit_length desc;
-- update fcpf_subnat_cea set geom_simple = ST_MULTI(st_buffer(st_simplify(st_buffer(st_buffer(st_simplify(wkb_geometry, 300), 500), -500), 2000), 0)) where hasc_1 = 'CL.AI' or hasc_1 = 'CL.MA';
-- select hasc_1 from fcpf_subnat_cea where not st_isvalid(geom_simple) or st_area(geom_simple) < 1;

Keybase proof

I hereby claim:

  • I am demiurg on github.
  • I am demiurge (https://keybase.io/demiurge) on keybase.
  • I have a public key whose fingerprint is E936 0C2A FA92 1934 3F02 8E05 76D3 30F5 5D80 B570

To claim this, I am signing this object: