Skip to content

Instantly share code, notes, and snippets.

View bitner's full-sized avatar

David Bitner bitner

View GitHub Profile

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:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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.
CREATE OR REPLACE FUNCTION xyzsearch_asmvtrows(
IN _x int,
IN _y int,
IN _z int,
IN queryhash text,
IN fields jsonb DEFAULT NULL,
IN _scanlimit int DEFAULT 10000,
IN _limit int DEFAULT 100,
IN _timelimit interval DEFAULT '5 seconds'::interval,
IN exitwhenfull boolean DEFAULT TRUE, -- Return as soon as the passed in geometry is full covered
@bitner
bitner / neo4j-to-json
Created September 27, 2021 19:19
neo4j-to-json
MATCH (n:DataProduct) WHERE id(n) = 6737 CALL apoc.path.expand(n, ">", "*", 1, 4) YIELD path WITH collect(path) as paths CALL apoc.convert.toTree(paths) yield value RETURN value
@bitner
bitner / pgstacdataload.py
Created September 27, 2021 19:31
pgstacdataload
‎‎​
@bitner
bitner / pgstacdataload.sh
Last active September 27, 2021 20:15
pgstacdataload.sh
#!/bin/bash
TMP_TABLE_RANDOM=$(tr -dc a-z </dev/urandom | head -c 20)
TABLE="pgstac.tmp_items_$TMP_TABLE_RANDOM"
psql <<EOD
CREATE UNLOGGED TABLE $TABLE (
-- id text GENERATED ALWAYS AS (content->>'id') STORED,
-- partition text GENERATED ALWAYS AS (items_partition_name(stac_datetime(content))) STORED,
content jsonb
);
EOD
@bitner
bitner / httptests.http
Last active October 8, 2021 15:56
httptests.http
POST https://planetarycomputer.microsoft.com/api/stac/v1/search HTTP/1.1
content-type: application/json
{
"bbox":[-59.69, -34.74, -58.24, -33.65],
"datetime":"2017-01-01/2020-12-31",
"collections":["sentinel-2-l2a"],
"limit":5
}
@bitner
bitner / landsat_centroid_poly.sql
Last active October 13, 2021 14:01
landsat_centroid_poly.sql
CREATE OR REPLACE FUNCTION landsat(
-- mandatory parameters
xmin float,
ymin float,
xmax float,
ymax float,
epsg integer
)
RETURNS bytea AS $$
WITH bounds AS (