-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
165 lines (150 loc) · 10.8 KB
/
index.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html>
<head>
<title></title><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<style type='text/css'>
body {
font-family: 'Tahoma';
letter-spacing:-2px;
background:#fff;
background-size:100%;
color:#000;
margin:0;
padding:0;
font-weight:bold;
}
h1, h2, h3, p {
margin:0;
}
em, a {
font-style:normal;
color:#94d;
}
strong {
font-style:normal;
color:#0a9ec1;
}
code {
font-style:normal;
font-family: 'Tahoma';
color:#d34;
}
a {
background:#1b9e77;
color:#fff;
text-decoration:none;
}
img {
width:100%;
}
div {
cursor:pointer;
cursor:hand;
position:absolute;
top:0;
left:0;
}
</style>
<script type='text/javascript'>
window.onload = function() {
var s = document.getElementsByTagName('div'), cur = 0;
if (!s) return;
function go(n) {
cur = n;
var i = 1e3, e = s[n];
for (var k = 0; k < s.length; k++) s[k].style.display = 'none';
e.style.display = 'inline';
e.style.fontSize = i + 'px';
if (e.firstChild.nodeName === 'IMG') {
document.body.style.backgroundImage = 'url(' + e.firstChild.src + ')';
e.firstChild.style.display = 'none';
} else {
document.body.style.backgroundImage = '';
document.body.style.backgroundColor = e.style.backgroundColor;
}
while (
e.offsetWidth > window.innerWidth ||
e.offsetHeight > window.innerHeight) {
e.style.fontSize = (i -= 10) + 'px';
if (i < 0) break;
}
e.style.marginTop = ((window.innerHeight - e.offsetHeight) / 2) + 'px';
if (window.location.hash !== n) window.location.hash = n;
document.title = e.textContent || e.innerText;
}
document.onclick = function() {
go(++cur % (s.length));
};
document.onkeydown = function(e) {
(e.which === 39) && go(Math.min(s.length - 1, ++cur));
(e.which === 37) && go(Math.max(0, --cur));
};
function parse_hash() {
return Math.max(Math.min(
s.length - 1,
parseInt(window.location.hash.substring(1), 10)), 0);
}
if (window.location.hash) cur = parse_hash() || cur;
window.onhashchange = function() {
var c = parse_hash();
if (c !== cur) go(c);
};
go(cur);
};
</script>
</head>
<body>
<div>after this finishes loading, use the arrow keys to change slides or <br/><em>view this presentation in markdown with notes</em> <a target="_blank" href="https://github.com/pdxmele/python-geodata-bffs/blob/master/presentation.md">here</a></div>
<!-- Introduction -->
<div><a target="_blank" href="http://github.com/pdxmele/python-geodata-bffs/">Python + geographic data = BFFs</a><br/>Mele Sax-Barnett<br/><strong>http://bit.ly/python-geo-bffs</strong></div>
<div><img src="img/Cat_and_dog_friends.jpg"><em>why?</em><br/><br/></div>
<div><img src="img/map1.png">I <code><3</code> maps, but making them can be <br/>a pain</div>
<div>the <code>worst</code> part is</div>
<div><img src="img/data.gif"><em>getting data to cooperate</em></div>
<div><img src="img/formats.png">it is usually <code>not</code> in the <a target="_blank" href="http://www.gdal.org/ogr/ogr_formats.html">format</a> you need</div>
<div><img src="img/nullisland.png">has several <code>obvious errors</code></div>
<div><img src="img/FolderStack.jpg">is split up into <code>50</code> <br/>different files</div>
<div><img src="img/azimuthal.jpg">is in a <br/><code>completely <br/>different projection</code><br/>than what you need<br/><br/></div>
<div><img src="img/noideadog.jpg">and has no <a target="_blank" href="https://www.fgdc.gov/metadata">metadata</a>,<br/> so you have <code>no idea</code><br/> what you're even looking at</div>
<div>you could point and click all day in <br/>out-of-the-box <br/><a target="_blank" href="http://en.wikipedia.org/wiki/Geographic_information_system">GIS</a> software,<br/><em>or you could use Python</em></div>
<!-- About Geographic Data-->
<div><em>about (vector) </em><a target="_blank" href="http://en.wikipedia.org/wiki/GIS_file_formats">geodata</a>:<br/><ul><li>made up of one or several files</li><li>with a coordinate system/<a target="_blank" href="http://en.wikipedia.org/wiki/Map_projection">projection</a></li><li>made up of one or several "<strong>layers</strong>" of data</li><li>each of which includes 1+ <strong>features</strong></li><li>each feature has <strong>geometry</strong>:</li><ul><li><strong>type</strong>: point/line/polygon/etc.</li><li><strong>coordinates</strong></li></ul><li>each feature also has various other attributes/<strong>properties</strong></li></ul></div>
<!-- Conversion / Fiona -->
<div><strong>Python packages:</strong><br/>convert and filter your data with <a target="_blank" href="https://pypi.python.org/pypi/fiona">Fiona</a></div>
<div><strong>example:</strong><br/> converting country shapefile data from <a target="_blank" href="http://www.naturalearthdata.com/">Natural Earth</a> to GeoJSON format</div>
<div>1. download <a target="_blank" href="http://www.naturalearthdata.com/downloads/110m-cultural-vectors/">some data</a><br/>2. <img src="img/fionacode1.png"><br/>you can also <br/><a target="_blank" href="http://toblerity.org/fiona/manual.html#filtering">filter by bounding box</a></div>
<div><img src="img/fiona1.png">3. enjoy!</div>
<div><strong>another Python package:</strong><br/>combine Fiona with <a target="_blank" href="https://pypi.python.org/pypi/pyproj">PyProj</a> to change the projection</div>
<div>1. <img src="img/proj1code.png"></div>
<div>... <img src="img/proj2code.png"></div>
<div><img src="img/proj.png">2. enjoy!<br/><br/></div>
<div><strong>one more <br/>Fiona example:</strong><br/> assemble a folder of <br/>GPX tracks into <br/>a single GeoJSON file</div>
<div>1. export some data in GPX format<br/>2. <img src="img/fionacode2.png"></div>
<div><img src="img/fiona2.png">3. enjoy!<br/><br/><br/><br/></div>
<!-- GeoJSON diversion -->
<div>before we go any further, <br/>let's talk about <a target="_blank" href="http://geojson.org/">GeoJSON</a>:</br></br>* <strong>JSON</strong> for geodata</br>* easy to use for <strong>web mapping</strong></br>* easy to <strong>parse with Python</strong></div>
<div>all you need to do is <code><br/>treat it like a dictionary</code></div>
<div><strong>example:</strong><br/><a target="_blank" href="http://osm.org">OpenStreetMap</a> data to map-ready GeoJSON</div>
<div>1. download some data</br><img src="img/osm_start.png"></div>
<div>2. convert it to GeoJSON with <br/><a target="_blank" href="https://github.com/pdxmele/gwyw-osm/blob/master/converters.md">your tool of choice</a>,<br/> or you can parse the XML directly</div>
<div>3. process</br><img src="img/geojsoncode1.png"><br/></div>
<div>...<img src="img/geojsoncode2.png"></div>
<div><img src="img/osm_done.png">4. <code>enjoy!</code></div>
<div><strong>or do this with CSV/XML data:</strong><br/>just put it in a dictionary and assemble valid GeoJSON with <em>only the features and attributes that you want</em>.<br/>if you have a lot of data, switch to reading and writing line-by-line.</div>
<div>because it's just a dictionary, it's easy to <code>create tests</code> for the data:<br/><ul><li>check for <strong>required keys</strong></li><li>check <em>the type</em> of each key's value</li><li>check against <strong>known values</strong></li><li>check <em>the structure</em></li><li>check for <strong>valid geometry</strong></li></ul></div>
<div>this is important if your system expects <br/>a very particular format, <br/>while your data comes from <code>a variety of sources</code><br/><img src="img/ua_ss.png"></div>
<!-- Shapely -->
<div><em>spatial analysis</em> and <br/>data manipulation <br/>with <a target="_blank" href="https://pypi.python.org/pypi/shapely">Shapely</a><br/><br/></div>
<div><a target="_blank" href="http://toblerity.org/shapely/manual.html">tons of examples in the manual</a>: <br/>validate and construct geometry, simplify, buffer, convex hull, envelope, offset, merge, union, interpolate, create polygons from lines, get centroid or representative point, bounds, area, or length, the distance between two objects, check if they are equal or almost equal, get the difference or symmetrical difference, see if one contains the other, if they intersect or touch, work with 3D data and Numpy, etc.</div>
<div><strong>example:</strong><br/> keep only <br/>the GPX tracks <br/>in Portland</div>
<div>1. get Portland or your city as GeoJSON<br/>2. <img src="img/shapelycode.png"></div>
<div><img src="img/shapelyresult.png"><br/><br/>3. enjoy!</div>
<div>another option for geoprocessing without <br/>GIS software: <a target="_blank" href="http://postgis.net/">PostGIS</a><br/><br/>talk to it with <a target="_blank" href="https://pypi.python.org/pypi/psycopg2/">Psycopg2</a> or your Python PostgreSQL tool of choice</div>
<!-- Wrap it up -->
<div>finally, GIS software <code><3</code>s Python</div>
<div><a target="_blank" href="http://resources.arcgis.com/en/communities/python/">ArcGIS</a>:<br/>http://resources.arcgis.com/en/communities/python/<br/><img src="img/arcgis.png"><br/><a target="_blank" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//000v00000001000000#GUID-4EC90E5F-F497-4FC0-99FB-7703ED4C8F77">arcpy</a> scripting and <a target="_blank" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//014p00000025000000">add-ins</a></div>
<div><a target="_blank" href="http://www.qgis.org/en/docs/pyqgis_developer_cookbook/intro.html">QGIS</a>:<br/>http://www.qgis.org/en/docs/pyqgis_developer_cookbook/intro.html<br/><br/><img src="img/qgis.png"><br/><br/>console, module, plugins, and development</div>
<div><img src="img/qgisplugins2.png"><br/><br/><br/><a target="_blank" href="https://plugins.qgis.org/">> 250 plugins</a></div>
<div><em>thank you!</em><br/><br/>questions? <a target="_blank" href="https://twitter.com/pdxmele">@pdxmele</a> or file an issue <a target="_blank" href="https://github.com/pdxmele/python-geodata-bffs">here</a></br>more resources <a target="_blank" href="https://github.com/pdxmele/python-geodata-bffs/blob/master/resources.md">here</a><br/></div>
</body>
</html>