Skip to content

Instantly share code, notes, and snippets.

View bitner's full-sized avatar

David Bitner bitner

View GitHub Profile
@bitner
bitner / openaq_data_compare.sql
Last active July 15, 2020 18:35
OpenAQ Data Compare Queries
-- PostgreSQL
select
row_number() over (order by date_utc asc, location, parameter),
location,
value,
parameter,
country,
city,
date_utc
from measurements
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am bitner on github.
  • I am bitnerd (https://keybase.io/bitnerd) on keybase.
  • I have a public key ASCD1E80x-4AWJUNeaONZr7VKLa43MIFndIcsKECkh5QtAo

To claim this, I am signing this object:

@bitner
bitner / phenomenagrid.sql
Created February 12, 2020 18:43
Create a grid to aggregate phenomena by.
-- Procedural Function that takes in an extent and a cellsize (in extent srid units)
-- And creates a grid bounding that extent with given cellsize with an origin that is in
-- a multiple of the cellsize + zero
CREATE OR REPLACE FUNCTION ST_GRID(
IN _extent geometry,
IN _cellsize float8,
OUT id bigint,
OUT r integer,
OUT c integer,
OUT geom geometry
@bitner
bitner / Fun with time
Last active February 22, 2017 08:50
-- Convenience Functions
CREATE OR REPLACE FUNCTION to_epoch(IN timestamptz, OUT epoch float8) AS
$$ SELECT extract(epoch from $1) $$ LANGUAGE SQL;
CREATE OR REPLACE FUNCTION ts_at_tod(IN timestamptz, IN timetz, OUT timestamptz) AS
$$ SELECT date($1) + $2 $$ LANGUAGE SQL;
-- Get list of target time between start and end
CREATE OR REPLACE FUNCTION times_between(IN range_start timestamptz, IN range_end timestamptz, IN t timetz)
RETURNS setof timestamptz AS $$
SELECT * FROM
==> django-osgeo-importer: self.distribution.run_command(command)
==> django-osgeo-importer:
==> django-osgeo-importer: File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
==> django-osgeo-importer:
==> django-osgeo-importer: cmd_obj.run()
==> django-osgeo-importer:
==> django-osgeo-importer: File "/tmp/pip_build_root/numpy/numpy/distutils/command/build_src.py", line 147, in run
==> django-osgeo-importer:
==> django-osgeo-importer: self.build_sources()
==> django-osgeo-importer:
CREATE OR REPLACE FUNCTION public.dbs_ned_z(
IN text,
IN text,
OUT text)
RETURNS text AS
$BODY$
#!/bin/sh
url="http://ned.usgs.gov/epqs/pqs.php?output=json&x=$1&y=$2"; /usr/bin/curl -s $url
$BODY$
LANGUAGE plsh VOLATILE
bitner@dbspatialtest:/var/www/iDtest/iD$ make
cat css/reset.css css/map.css css/app.css css/feature-icons.css > dist/iD.css
node build.js
/var/www/iDtest/iD/node_modules/d3/node_modules/jsdom/lib/jsdom/level1/core.js:432
set nodeName() { throw new core.DOMException();},
^
SyntaxError: Unexpected token )
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
WITH t AS (
SELECT id, (SELECT min(val), max(val) FROM mytable WHERE st_dwithin(geom,a.geom,16093)) b,geom FROM mytable a
)
SELECT id, (b).min, (b).max, geom FROM t
SELECT 'MULTIPOLYGON(((-2.28716645489199 1.04616687844134,-2.46505717916137 1.2579415501906,-2.38034731046167 1.47395171537484,-2.17704362558238 1.55866158407454,-1.88055908513342 1.42312579415502,-1.87208809826345 1.17323168149089,-2.18127911901737 0.982634476916561,-2.26175349428208 0.766624311732317,-2.09233375688268 0.631088521812791,-1.79161372299873 0.796272765777213,-1.55866158407454 0.732740364252435,-1.43159678102499 0.550614146548073,-1.43583227445997 0.461668784413384,-1.53748411689962 0.436255823803473,-1.32147395171537 0.321897501058873,-1.13087674714104 0.0720033883947477,-1.06310885218128 -0.23718763235917,-0.910631088521813 -0.203303684879289,-1.43159678102499 -0.309191020753918,-1.69419737399407 -0.309191020753918,-1.71113934773401 -0.249894112664126,-1.8297331639136 -0.330368487928844,-2.01609487505294 -0.262600592969081,-1.97373994070309 -0.207539178314274,-2.14739517153748 -0.190597204574333,-2.00762388818297 0.448962304108429,-2.13468869123253 0.470139771283354,-2.33375688267683 0.7115628