Skip to content

Instantly share code, notes, and snippets.

View JimShady's full-sized avatar

James JimShady

View GitHub Profile
@JimShady
JimShady / test.R
Last active April 28, 2023 13:21
Confusion around gdal options in terra
# This works
test_extent <- ext(rast("lk_run_2023-04-27-15-05-37_30m_aal.tif"))
rast_input <- rast("global_commercial_base_annual_average_damage_ratio.tif", win = test_extent)
lapp(rast_input,
fun = function(x) {x/10000},
filename = "global_commercial_base_annual_average_damage_ratio_floating_point.tif",
wopt = list(datatype = "FLT4S"),
overwrite = TRUE)
@JimShady
JimShady / index.html
Last active February 23, 2016 16:27
D3 scatterplot v2
<!DOCTYPE html>
<html>
<head>
<!-- Load D3 from site -->
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<!-- CSS (Styling) -->
<style type="text/css">
@JimShady
JimShady / index.html
Last active February 23, 2016 16:42
D3 Scatterplot development
<html>
<head>
<title>The d3 test</title>
<style>
.chart {
}
.main text {
font: 10px sans-serif;
@JimShady
JimShady / README.md
Last active October 8, 2015 20:20 — forked from jasondavies/.block
Parallel Coordinates

Test

@JimShady
JimShady / OSMBuildings-Leaflet.js
Last active August 29, 2015 14:17
Pollution Selector + Buildings
(function(aa){function T(b,a){var c=b.x-a.x,d=b.y-a.y;return c*c+d*d}function wa(b){var a=b.length;if(16>a)return!1;var c,d=Infinity,f=-Infinity,h=Infinity,g=-Infinity;for(c=0;c<a-1;c+=2)d=Math.min(d,b[c]),f=Math.max(f,b[c]),h=Math.min(h,b[c+1]),g=Math.max(g,b[c+1]);c=f-d;g-=h;f=c/g;if(0.85>f||1.15<f)return!1;d={x:d+c/2,y:h+g/2};c=(c+g)/4;h=c*c;for(c=0;c<a-1;c+=2)if(g=T({x:b[c],y:b[c+1]},d),0.8>g/h||1.2<g/h)return!1;return!0}function ka(b,a){var c={};b/=U;a/=U;var d=xa,f;f=0>=a?90:1<=a?-90:(2*ya(za(F*
(1-2*a)))-J)/F*180;c[d]=f;c[Aa]=360*(1===b?1:(b%1+1)%1)-180;return c}function da(b,a){var c=V(1,K(0,0.5-Ba(la(Ca+J*b/180))/F/2));return{x:(a/360+0.5)*U<<0,y:c*U<<0}}function W(b){for(var a=D+q,c=B+n,d=0,f=b.length-3;d<f;d+=2)if(b[d]>q&&b[d]<a&&b[d+1]>n&&b[d+1]<c)return!0;return!1}function Da(){M||(M=setInterval(function(){for(var b=C.items,a=!1,c=0,d=b.length;c<d;c++)1>b[c].scale&&(b[c].scale+=0.1,1<b[c].scale&&(b[c].scale=1),a=!0);x.render();a||(clearInterval(M),M=null)},33))}function ea(b){N=X+
b.x;O=B+b.y;x.r
@JimShady
JimShady / OSMBuildings-Leaflet.js
Last active August 29, 2015 14:16
3D Buildings + Pollution
(function(aa){function T(b,a){var c=b.x-a.x,d=b.y-a.y;return c*c+d*d}function wa(b){var a=b.length;if(16>a)return!1;var c,d=Infinity,f=-Infinity,h=Infinity,g=-Infinity;for(c=0;c<a-1;c+=2)d=Math.min(d,b[c]),f=Math.max(f,b[c]),h=Math.min(h,b[c+1]),g=Math.max(g,b[c+1]);c=f-d;g-=h;f=c/g;if(0.85>f||1.15<f)return!1;d={x:d+c/2,y:h+g/2};c=(c+g)/4;h=c*c;for(c=0;c<a-1;c+=2)if(g=T({x:b[c],y:b[c+1]},d),0.8>g/h||1.2<g/h)return!1;return!0}function ka(b,a){var c={};b/=U;a/=U;var d=xa,f;f=0>=a?90:1<=a?-90:(2*ya(za(F*
(1-2*a)))-J)/F*180;c[d]=f;c[Aa]=360*(1===b?1:(b%1+1)%1)-180;return c}function da(b,a){var c=V(1,K(0,0.5-Ba(la(Ca+J*b/180))/F/2));return{x:(a/360+0.5)*U<<0,y:c*U<<0}}function W(b){for(var a=D+q,c=B+n,d=0,f=b.length-3;d<f;d+=2)if(b[d]>q&&b[d]<a&&b[d+1]>n&&b[d+1]<c)return!0;return!1}function Da(){M||(M=setInterval(function(){for(var b=C.items,a=!1,c=0,d=b.length;c<d;c++)1>b[c].scale&&(b[c].scale+=0.1,1<b[c].scale&&(b[c].scale=1),a=!0);x.render();a||(clearInterval(M),M=null)},33))}function ea(b){N=X+
b.x;O=B+b.y;x.r
@JimShady
JimShady / index.html
Last active August 29, 2015 14:13
PM2.5 Levels on the London Underground
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script type="text/javascript" src="http://calvinmetcalf.github.io/leaflet-ajax/dist/leaflet.ajax.js"></script>
<script type="text/javascript" src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<style>
body {
padding: 0;
margin: 0;
@JimShady
JimShady / README.md
Last active August 29, 2015 14:04
Mapping air quality and GPS data

A demonstration of mapping air pollutio and GPS data simultaneously.

@JimShady
JimShady / README.md
Last active August 29, 2015 14:04 — forked from mbostock/.block
BBC Microaeth data

This data shows the BBC PM2.5 data collected in July 2014. Missing data is represented with a straight line between the last and next points.

@JimShady
JimShady / README.md
Last active August 29, 2015 14:04
BBC PM2.5 data collected in July 2014

This graph shows PM2.5 data collected by BBC reporters over the 28 and 29 of July 2014. The raw data was collected via a Microaeth A51, downloaded, reformatted, and then multiplied by 0.6.