Skip to content

Instantly share code, notes, and snippets.

View peterdesmet's full-sized avatar

Peter Desmet peterdesmet

View GitHub Profile
@peterdesmet
peterdesmet / LatLong Crosshairs.js
Last active January 2, 2016 19:28
LatLong Crosshairs for Google Maps by Pierre Bélisle and Peter Desmet for Canadensys. http://www.canadensys.net/latlong-crosshairs
javascript:var coord;var output;var xhs;if(!document.getElementById('xhs')){xhs=document.createElement('div');xhs.setAttribute('id','xhs');xhs.setAttribute('style', 'background:url(\'http://www.canadensys.net/crosshair.png\') top left no-repeat;position:absolute;top:50%;left:50%;margin-top:-7px;margin-left:-7px;height:15px;width:15px;');xhs.onclick=function(){coord = [gApplication.getMap().getCenter().lat(),gApplication.getMap().getCenter().lng()];output = Math.round(coord[0]*10000000)/10000000 + '\t' + Math.round(coord[1]*10000000)/10000000;prompt('Latitude and Longitude',output);};void(document.getElementById('map').appendChild(xhs));}else{void(document.getElementById('map').removeChild(xhs));}
@peterdesmet
peterdesmet / cc0-organizations.md
Last active January 3, 2016 08:39
List of organizations in the field of life sciences requiring CC0 for submitted data.
@peterdesmet
peterdesmet / ericFlightPaths.css
Last active January 4, 2016 02:29
CartoDB CSS and SQL to visualize flight tracks of gull Eric grouped by seasonal behaviour.
/** category visualization */
#bird_tracking {
line-width: 1;
line-opacity: 0.9;
}
#bird_tracking[behaviour="1. Egg incubation"] {
line-color: #b81609;
}
@peterdesmet
peterdesmet / ericFlightPathsTorque.css
Last active January 4, 2016 02:29
CartoDB CSS and SQL to visualize flight tracks of gull Eric grouped by seasonal behaviour in Torque. Expressing the seasonal behaviour as a number allows Torque to differentiate between those.
/** torque visualization */
Map {
-torque-frame-count:512;
-torque-animation-duration:40;
-torque-time-attribute:"date_time";
-torque-aggregation-function:"avg(behaviour_number)";
-torque-resolution:1;
-torque-data-aggregation:linear;
}
@peterdesmet
peterdesmet / ericSuperimposedDailyTorque.css
Last active August 29, 2015 13:56
CartoDB CSS and SQL to visualize flights of gull Eric with days superimposed on each other.
/** torque visualization */
Map {
-torque-frame-count:2048;
-torque-animation-duration:30;
-torque-time-attribute:"date_time";
-torque-aggregation-function:"count(cartodb_id)";
-torque-resolution:1;
-torque-data-aggregation:linear;
}
@peterdesmet
peterdesmet / rbins_radar_prepare_data.sql
Last active August 29, 2015 14:07
SQL queries to dive into the data from the RBINS radar.
ALTER TABLE rbins_radar_occurrences
RENAME COLUMN expr1000 to date;
ALTER TABLE rbins_radar_occurrences
ALTER COLUMN area SET data type integer USING area::integer;
ALTER TABLE rbins_radar_occurrences
ALTER COLUMN av_reflectivity SET data type integer USING av_reflectivity::integer;
ALTER TABLE rbins_radar_occurrences
ALTER COLUMN date SET data type timestamp with time zone USING date::timestamp with time zone;
ALTER TABLE rbins_radar_occurrences
@peterdesmet
peterdesmet / belgian-lambert-to-wgs84.sql
Last active August 29, 2015 14:07
Transform Belgian Lambert to WGS84 in PostgreSQL
-- SetSRID defines the datum. Use 31370, not 31300 for Belgian Lambert 72
SELECT
*,
ST_Transform(ST_SetSRID(ST_MakePoint(x,y),31370),4326) as geom_from_lambert,
ST_Y(ST_Transform(ST_SetSRID(ST_MakePoint(x,y),31370),4326)) as latitude_from_lambert,
ST_X(ST_Transform(ST_SetSRID(ST_MakePoint(x,y),31370),4326)) as longitude_from_lambert
FROM table_name
@peterdesmet
peterdesmet / 88c30be4-1063-11e5-a9ae-0e853d047bba.md
Last active March 16, 2018 14:29
Bird migration forward trajectory visualizations in CartoDB
@peterdesmet
peterdesmet / open-belgium-blog-post-2016.md
Last active February 11, 2016 11:13
Open Belgium 2016 blog post on Open Refine

Let your data shine... with OpenRefine

“Google refine is awesome. Never before have I been home this early.” - @salesient

@peterdesmet
peterdesmet / get_gbif_datasets.py
Last active May 11, 2016 07:51
Python script to get specific metadata from GBIF-registered datasets.
# -*- coding: utf-8 -*-
import requests
import json
import csv
import sys
def get_datasets(offset, limit):
sys.stderr.write('Requesting batch {}\n'.format(offset)) # Use stderr to not contaminate stdout, which is used for the results
request = requests.get('http://api.gbif.org/v1/dataset/', params={'limit': limit, 'offset': offset})
results = request.json()['results']