-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbc-topo-frankenmap.html
119 lines (104 loc) · 5.63 KB
/
bc-topo-frankenmap.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html lang="en" prefix="og: http://ogp.me/ns#">
<head>
<link href="http://gmpg.org/xfn/11" rel="profile">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!-- Metadata -->
<meta name="description" content="">
<meta property="og:description" content="">
<meta property="og:title" content="BC Topo Frankenmap" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://darrenwiens.github.io/bc-topo-frankenmap.html" />
<meta property="og:image" content="https://darrenwiens.github.io/images/face.png" />
<!-- Enable responsiveness on mobile devices-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<title>Darren Wiens</title>
<!-- CSS -->
<link href="//fonts.googleapis.com/" rel="dns-prefetch">
<link href="//fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic|Abril+Fatface|PT+Sans:400,400italic,700&subset=latin,latin-ext" rel="stylesheet">
<link rel="stylesheet" href="https://darrenwiens.github.io/theme/css/poole.css" />
<link rel="stylesheet" href="https://darrenwiens.github.io/theme/css/hyde.css" />
<link rel="stylesheet" href="https://darrenwiens.github.io/theme/css/syntax.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/fork-awesome.min.css" crossorigin="anonymous">
<!-- Feeds -->
<!-- Analytics -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-9664J8VT36"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-9664J8VT36');
</script>
<!-- Ads -->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2681534008399266"
crossorigin="anonymous"></script>
</head>
<body class="theme-base-08">
<div class="sidebar">
<div class="container sidebar-sticky">
<div class="sidebar-about">
<h1>
<a href="/">
<img class="profile-picture" src="https://darrenwiens.github.io/images/face.png">
Darren Wiens
</a>
</h1>
<p class="lead"></p>
<p class="lead"> </p>
<p></p>
</div>
<ul class="sidebar-nav">
</ul>
<nav class="sidebar-social">
<a class="sidebar-social-item" href="http://twitter.com/dkwiens" target="_blank">
<i class="fa fa-twitter"></i>
</a>
<a class="sidebar-social-item" href="https://fosstodon.org/@dkwiens" target="_blank">
<i class="fa fa-mastodon"></i>
</a>
<a class="sidebar-social-item" href="http://github.com/darrenwiens" target="_blank">
<i class="fa fa-github"></i>
</a>
<a style="display:none" class="sidebar-social-item" href="https://darrenwiens.github.io/None">
<i class="fa fa-rss"></i>
</a>
<a rel="me" style="display:none" href="https://fosstodon.org/@dkwiens">Mastodon</a>
</nav>
</div>
</div> <div class="content container">
<div class="post">
<h1 class="post-title">BC Topo Frankenmap</h1>
<span class="post-date">Mon 18 October 2021</span>
<p><a href="https://www.rayshader.com/">Rayshader</a> is a really amazing <a href="https://www.r-project.org/">R</a> module for creating 2D and 3D visualizations. As a Python developer, I've been jealous and curious about these visuals, so I set about using it, in the way I think God intended - a Python Jupyter notebook.</p>
<p>Even though I want to use Python for the bulk of the workflow, rayshader is an R module, regardless how I want to use it, which means I need to interact with rayshader through R. We can do that from within a Python Jupyter notebook environment using <a href="https://rpy2.github.io/doc/v3.3.x/html/notebooks.html">rpy2</a>.</p>
<p>It's pretty easy, once everything is installed successfully. Load the extension with:</p>
<div class="highlight"><pre><span></span><code><span class="nf">%load_ext</span><span class="w"> </span><span class="n">rpy2</span><span class="p">.</span><span class="n">ipython</span><span class="w"></span>
</code></pre></div>
<p>Then, switch any cell to R using the <code>%%R</code> magic (optionally, pass variables from Python using the <code>-i</code> flag):</p>
<div class="highlight"><pre><span></span><code><span class="c">%%R</span><span class="w"></span>
<span class="n">R</span><span class="p">.</span><span class="n">version</span><span class="p">.</span><span class="n">string</span><span class="w"></span>
</code></pre></div>
<p>Now, to an example. The idea here is that I want an animation in which we show a BC 250K mapsheet, in which the mapsheet area itself is shown as raised elevation.</p>
<p><img alt="BC Topo animation" src="https://darrenwiens.github.io/images/bc_topo.gif"></p>
<p>Data sources:</p>
<ul>
<li>NTS 250K mapsheet: <a href="https://a100.gov.bc.ca/ext/mtec/public/products/mapsheet">BC Maps & Orthos</a></li>
<li>CDEM elevation: <a href="https://ftp.maps.canada.ca/pub/nrcan_rncan/elevation/cdem_mnec/">FTP</a></li>
</ul>
<p>You can find the notebook <a href="https://gist.github.com/darrenwiens/838fda98fc227259ab0655e13a658a10">here</a>.</p>
<p>Get in touch with me on <a href="https://twitter.com/dkwiens">Twitter</a> if you want to continue the discussion!</p>
<span class="post-tags">
Tags:
<ul>
<li><a href="https://darrenwiens.github.io/tag/python.html">python</a></li>
<li><a href="https://darrenwiens.github.io/tag/r.html">r</a></li>
<li><a href="https://darrenwiens.github.io/tag/rayshader.html">rayshader</a></li>
<li><a href="https://darrenwiens.github.io/tag/jupyter.html">jupyter</a></li>
</ul>
</span>
</div>
</div>
</body>
</html>