<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CE8HQnszcSp7ImA9WhBbGE8.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187</id><updated>2013-05-17T21:33:53.589+01:00</updated><category term="TileMill" /><category term="Google Maps" /><category term="CartoDB" /><category term="MBTiles" /><category term="KML" /><category term="QGIS" /><category term="Google Earth" /><category term="MySQL" /><category term="Open Data" /><category term="Leaflet" /><category term="Choropleth" /><category term="Map tiling" /><category term="Thematic mapping" /><category term="OGR" /><category term="OpenLayers" /><category term="Google Chart" /><category term="GDAL/OGR" /><category term="MapBox" /><title>thematic mapping blog</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.thematicmapping.org/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>100</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/thematicmapping" /><feedburner:info uri="thematicmapping" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-sa/3.0/" /><logo>http://creativecommons.org/images/public/somerights20.gif</logo><feedburner:emailServiceId>thematicmapping</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;CUINQH44cCp7ImA9WhBUE0g.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-7090579800209236620</id><published>2013-04-30T21:14:00.001+01:00</published><updated>2013-04-30T21:26:31.038+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-30T21:26:31.038+01:00</app:edited><title>Norway will open its topographic datasets to the public!</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Today, 30th April 2013, is a milestone of the mapping history of Norway. Together with two governmental ministers, the Norwegian Mapping Authority&amp;nbsp;&lt;a href="http://www.digi.no/"&gt;announced&lt;/a&gt; they will open its topographic datasets to the public, free of charge. Norway will follow progressive countries like Denmark, Finland and &lt;a href="http://blog.thematicmapping.org/2012/09/getting-free-data-in-new-zealand.html"&gt;New Zealand&lt;/a&gt;, considering geographic data as a public good. &lt;br /&gt;
&lt;br /&gt;
The topographic datasets at 1:50,000 scale will be freely available later this year, together with address, road and cadastre data. A &lt;a href="http://www.kartverket.no/Kart/Kartdata/Stedsnavndata/Stedsnavn-fylkesvise-filer/"&gt;database of 950,000 place names&lt;/a&gt; was released to the public one month ago. Hopefully, digital elevation data will be free as well, but it's not yet stated.&lt;br /&gt;
&lt;br /&gt;
Cheers!&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-jxE0AawDSn8/T_HP5-EJAaI/AAAAAAAAKFA/ol7sP4L7684/s1600/jotunheimen_terrain3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://1.bp.blogspot.com/-jxE0AawDSn8/T_HP5-EJAaI/AAAAAAAAKFA/ol7sP4L7684/s640/jotunheimen_terrain3.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/6u8qMUO36mA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/7090579800209236620/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=7090579800209236620" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/7090579800209236620?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/7090579800209236620?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/6u8qMUO36mA/norway-will-open-its-topographic.html" title="Norway will open its topographic datasets to the public!" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-jxE0AawDSn8/T_HP5-EJAaI/AAAAAAAAKFA/ol7sP4L7684/s72-c/jotunheimen_terrain3.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2013/04/norway-will-open-its-topographic.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4EQn88cCp7ImA9WhBUEUs.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-7248772903343142456</id><published>2013-04-28T17:47:00.001+01:00</published><updated>2013-04-28T17:51:43.178+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-28T17:51:43.178+01:00</app:edited><title>Cross-country skiing in Norway</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
It's been a great winter in Norway. Pleny of snow, lots of sunshine and good skiing conditions, except from my last trip where we caught in a storm and luckily found our way back to the hut. Outdoors was what got me into mapping in the first place. A hike is much more enjoyable with a good trekking map, and on my last trip I really experienced how crucial a GPS can be.&lt;br /&gt;
&lt;br /&gt;
As I spent my free time skiing there's been no time for blogging, so I decied to post a few photos instead. Cross-country skiing in Norway is highly recommended!&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-K691DEDutHk/UX1Khjj2XrI/AAAAAAAAKwc/FZq4I8xpfvM/s1600/gaustatoppen.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-K691DEDutHk/UX1Khjj2XrI/AAAAAAAAKwc/FZq4I8xpfvM/s640/gaustatoppen.jpg" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Gaustatoppen"&gt;Mt. Gaustatoppen&lt;/a&gt;, where you can see&amp;nbsp;one sixth of Norways mainland from the top.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-VGpS7b5Un3w/UX1KeGI3YOI/AAAAAAAAKv4/C-Byu8i56Wg/s1600/1-P1150244.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-VGpS7b5Un3w/UX1KeGI3YOI/AAAAAAAAKv4/C-Byu8i56Wg/s640/1-P1150244.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;A view of &lt;a href="http://en.wikipedia.org/wiki/Rondane_National_Park"&gt;Rondane&lt;/a&gt;,&amp;nbsp;&amp;nbsp;the oldest national park in Norway.&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-dNG6qRMjvxs/UX1Ke4bFwwI/AAAAAAAAKv8/SGdDuHvK2bo/s1600/1-P1150568.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-dNG6qRMjvxs/UX1Ke4bFwwI/AAAAAAAAKv8/SGdDuHvK2bo/s640/1-P1150568.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Mountain pasture used for the grazing of sheep and cattle in the western part of Norway.&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-j74fEzO9c8s/UX1Kfk2i4LI/AAAAAAAAKwE/j68EGmzByKo/s1600/2-P1150578.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-j74fEzO9c8s/UX1Kfk2i4LI/AAAAAAAAKwE/j68EGmzByKo/s640/2-P1150578.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;By the &lt;a href="http://en.wikipedia.org/wiki/Hardangerfjord"&gt;Hardangerfjord&lt;/a&gt;, the&amp;nbsp;third largest fjord in the world.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-fCxyxLxTNQQ/UX1KhgJoTWI/AAAAAAAAKwg/x5hyXyMWhX4/s1600/5-P1150740.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-fCxyxLxTNQQ/UX1KhgJoTWI/AAAAAAAAKwg/x5hyXyMWhX4/s640/5-P1150740.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Skiing in &lt;a href="http://en.wikipedia.org/wiki/Dovre_National_Park"&gt;Dovre National Park&lt;/a&gt;.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
PS! I'll start a new blog series on mapping with &lt;a href="http://d3js.org/"&gt;D3.js&lt;/a&gt; in June. Stay tuned!&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/0bHq_4Gwqt0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/7248772903343142456/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=7248772903343142456" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/7248772903343142456?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/7248772903343142456?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/0bHq_4Gwqt0/winter-in-norway.html" title="Cross-country skiing in Norway" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-K691DEDutHk/UX1Khjj2XrI/AAAAAAAAKwc/FZq4I8xpfvM/s72-c/gaustatoppen.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2013/04/winter-in-norway.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEANQHczeCp7ImA9WhNQE0w.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-3204523538763841901</id><published>2012-11-18T21:48:00.000Z</published><updated>2012-11-19T09:19:51.980Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-19T09:19:51.980Z</app:edited><title>How to minify GeoJSON files?</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
You can't do web mapping these days without knowing your &lt;a href="http://www.geojson.org/geojson-spec.html"&gt;GeoJSON&lt;/a&gt;. It's the vector format of choice among popular mapping libraries like &lt;a href="http://leafletjs.com/"&gt;Leaflet&lt;/a&gt;, &lt;a href="http://d3js.org/"&gt;D3.js&lt;/a&gt; and &lt;a href="http://polymaps.org/"&gt;Polymaps&lt;/a&gt;. Size matters on the web, especially if you want to distribute complex geometries, like the world's countries. The challenge is even bigger if you want to target mobile users - or support web browsers with poor vector handling (IE &amp;lt; 9). This blog post will show you how to minify your GeoJSON files before sending them over the wire.&lt;br /&gt;
&lt;br /&gt;
The first thing you should do is to generalize your vectors so they don't contain more detail than you need. In &lt;a href="http://blog.thematicmapping.org/2012/10/mapping-regions-of-new-zealand-with.html"&gt;a previous blog post&lt;/a&gt;, I was able to remove 90% of the coordinates without loosing to much detail for map scale I wanted to use. This will of course have a great effect on the file size.&lt;br /&gt;
&lt;br /&gt;
Today, I'm going to use country borders from the &lt;a href="http://www.naturalearthdata.com/"&gt;Natural Earth dataset&lt;/a&gt;. These datasets are already generalized for different scales (1:10m, 1:50m, and 1:110 million), so I'll use them as they are. The 1:110m (small scale) and 1:50m (medium scale) shapefiles will cover the needs for the thematic world maps I plan to make:&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&amp;nbsp;&lt;a href="http://www.naturalearthdata.com/downloads/110m-cultural-vectors/110m-admin-0-countries/"&gt;110m-admin-0-countries&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;a href="http://www.naturalearthdata.com/downloads/50m-cultural-vectors/50m-admin-0-countries-2/"&gt;50m-admin-0-countries&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-wSUWdr3uFMU/UKktQnEPTdI/AAAAAAAAKsA/2oMsMzqsk-o/s1600/borders.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="399" src="http://2.bp.blogspot.com/-wSUWdr3uFMU/UKktQnEPTdI/AAAAAAAAKsA/2oMsMzqsk-o/s640/borders.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The 110m and 50m country polygons shown in QGIS. &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Let's open the datasets in &lt;a href="http://www.qgis.org/"&gt;QGIS&lt;/a&gt;. If you look at the attribute table you'll see that each dataset contains 63 attributes, which makes them very versatile. For your web maps, you probably need just a few of the attributes, and you should remove the ones you don't need. I'm keeping the country name and the &lt;a href="http://en.wikipedia.org/wiki/ISO_3166-1"&gt;ISO 3166-1 country codes&lt;/a&gt; (alpha-2, alpha-3, and numeric), which can be used to link country geometries to statistical data.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-Cy7bX18arFo/UKkwgX9qG0I/AAAAAAAAKs0/02YalI0knjI/s1600/attributes.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-Cy7bX18arFo/UKkwgX9qG0I/AAAAAAAAKs0/02YalI0knjI/s1600/attributes.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Only keep the attributes you need.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Next, we can convert the shapefiles to GeoJSON with &lt;a href="http://www.gdal.org/ogr2ogr.html"&gt;ogr2ogr&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ogr2ogr -f "GeoJSON" -lco COORDINATE_PRECISION=1 ne_110m_admin_0_countries.json ne_110m_admin_0_countries.shp &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ogr2ogr -f "GeoJSON" -lco COORDINATE_PRECISION=2 ne_50m_admin_0_countries.json ne_50m_admin_0_countries.shp&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The important thing is that I'm only keeping one decimal (coordinate precision) for the 110m dataset, and two decimals for the 50m dataset, which is sufficient for my map scales. This will reduce the size of the GeoJSON files by more than half. The size of the 110m GeoJSON is now 207 kB and the 50m version is 1,897 kB. But we can do better.&lt;br /&gt;
&lt;br /&gt;
The files contains a lot of whitespace, which is waste of space. I planned to use &lt;a href="http://www.sublimetext.com/"&gt;Sublime Text&lt;/a&gt; to remove the whitespace, but it were &lt;a href="http://sublimetext.userecho.com/topic/27988-better-handling-of-huge-files/"&gt;not able&lt;/a&gt; to handle the 50m GeoJSON file, so I switched to &lt;a href="http://notepad-plus-plus.org/"&gt;Notepad++&lt;/a&gt;. I used these &lt;a href="http://en.wikipedia.org/wiki/Regular_expression"&gt;regular expressions&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
Find: "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;([^a-z.]) &lt;/span&gt;"&lt;br /&gt;
Replace: "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$1&lt;/span&gt;"&lt;br /&gt;
This will remove all whitespace which is not succeeding a letter or a dot, which are present in country names.&lt;br /&gt;
&lt;br /&gt;
Find: "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;\n,&lt;/span&gt;"&lt;br /&gt;
Replace: "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;,&lt;/span&gt;" &lt;br /&gt;
Remove line breaks (keeping some for readability).&lt;br /&gt;
&lt;br /&gt;
Find: "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;\.0([,\]])&lt;/span&gt;"&lt;br /&gt;
Replace: "&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$1&lt;/span&gt;"&lt;br /&gt;
Remove trailing zeros.&lt;br /&gt;
&lt;br /&gt;
This will reduce the file size of the 110m GeoJSON from 207 to 156 kB, without loosing any data quality. More than 400k of whitespace characters was removed from the 50m GeoJSON file, reducing the file size from 1,897 to 1,481 kB.&lt;br /&gt;
&lt;br /&gt;
If your web server is supporting &lt;a href="http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/"&gt;gzipping on-the-fly&lt;/a&gt;, the 110m GeoJSON will end up being 45 kB and the 50m version will be 430 kB. Not bad!&lt;br /&gt;
&lt;br /&gt;
And if this is too much work, you can always &lt;a href="http://thematicmapping.org/downloads/ne-v2.0.0-countries-geojson.zip"&gt;download the final GeoJSON files on thematicmapping.org&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
NB! &lt;a href="http://draft.blogger.com/%3Ca%20href=%22https://github.com/mbostock/topojson%22%3E"&gt;Mike Bostock’s TopoJSON&lt;/a&gt; would allow us to compress the GeoJSON even more, while preserving topology (shared borders between countries) - but we would need to use a map client supporting the format. Looks promising!&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/CwvY_zsuZqc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/3204523538763841901/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=3204523538763841901" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/3204523538763841901?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/3204523538763841901?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/CwvY_zsuZqc/how-to-minify-geojson-files.html" title="How to minify GeoJSON files?" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-wSUWdr3uFMU/UKktQnEPTdI/AAAAAAAAKsA/2oMsMzqsk-o/s72-c/borders.png" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/11/how-to-minify-geojson-files.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak4ERXw9eyp7ImA9WhNRF0w.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-1377882018285501347</id><published>2012-11-04T19:18:00.004Z</published><updated>2012-11-12T11:15:04.263Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-12T11:15:04.263Z</app:edited><title>Mapping New Zealand - a summary</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I've had a fantastic two months study trip to New Zealand. Unfortunately, I had to go back to Norway this week to fill up my bank account - just when the summer was arriving in New Zealand. I'm going to miss the beautiful country with its great people.&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-oexDp-J8XwI/UJbOBtDe8rI/AAAAAAAAKrM/nVowvns1I3w/s1600/P1060436.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-oexDp-J8XwI/UJbOBtDe8rI/AAAAAAAAKrM/nVowvns1I3w/s640/P1060436.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
New Zealand is the perfect country to map, as an isolated country surrounded by a vast ocean, and because of all the free data available. I hope my Mapping New Zealand blog series has been useful for others as well: &lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/09/getting-free-data-in-new-zealand.html"&gt;Getting free data in New Zealand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-of-new-zealand.html"&gt;Creating a Seafloor Map of New Zealand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-using-shaded.html"&gt;Creating a seafloor map using shaded relief&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/09/creating-custom-map-tiling-scheme-for.html"&gt;Creating a custom map tiling scheme for New Zealand’s seafloor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/09/mapping-new-zealand-dealing-with.html"&gt;Dealing with the antimeridian in TileMill&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/09/mapping-new-zealand-editing-and-merging.html"&gt;Editing and merging shapefiles with QGIS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/09/creating-shaded-relief-map-of-new.html"&gt;Creating a shaded relief map of New Zealand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/09/mapping-new-zealand-doing-magic-with.html"&gt;Doing magic with TileMill&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/09/mapping-new-zealand-extracting-tiles.html"&gt;Exporting tiles from TileMill&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/10/mapping-new-zealand-using-leaflet-with.html"&gt;Creating a "Where I've Been" map with Leaflet and CartoDB&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/10/how-to-control-your-leaflet-map-with.html"&gt;How to control your Leaflet map with URL parameters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/10/mapping-new-zealand-where-are-hot-and.html"&gt;Where are the hot and cold springs?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/10/mapping-new-zealand-clustering-doc-huts.html"&gt;Clustering DOC Huts with Leaflet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/10/mapping-new-zealand-creating-road-map.html"&gt;Creating a road map&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/10/mapping-regions-of-new-zealand-with.html"&gt;Mapping the regions of New Zealand with MapShaper and Leaflet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/10/mapping-population-density-of-new.html"&gt;Mapping the population density of New Zealand with QGIS, SQLite and TileMill&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/11/exploring-mapbox-stack-mbtiles-tilejson.html"&gt;Exploring the MapBox stack: MBTiles, TileJSON, UTFGrids and Wax&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/11/creating-labels-with-tilemill.html"&gt;Creating map labels with TileMill&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.thematicmapping.org/2012/11/new-leaflet-plugin-to-handle-multiple.html"&gt;New Leaflet plugin to handle multiple TileMill layers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
It's a lot of exciting things happening on the New Zealand mapping scene, and the Kiwis are very welcoming people. I want to thank all the nice people I met on my journey, who was very willing to share their knowledge and experiences: &lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Organisers and participants at &lt;a href="http://web.env.auckland.ac.nz/public/geocart2012/"&gt;GeoCart'2012&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The &lt;a href="http://koordinates.com/"&gt;Koordinates.com&lt;/a&gt; guys &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.planetinaction.com/"&gt;PlanetInAction&lt;/a&gt; (Paul van Dinther), you should check out his great &lt;a href="http://www.gearthblog.com/blog/archives/2012/10/immerse_yourself_in_google_earth_wi.html"&gt;Google Earth based helicopter simulator&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Organsiers and participants at the &lt;a href="http://web.env.auckland.ac.nz/public/mcw2012/"&gt;Mountain Cartography Workshop&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The geospatial team at &lt;a href="http://www.landcareresearch.co.nz/"&gt;Landcare Research&lt;/a&gt; in Palmerston North.&lt;/li&gt;
&lt;li&gt;The mapsmiths at &lt;a href="http://geographx.co.nz/"&gt;Geographics&lt;/a&gt; - the best cartographers in New Zealand! &lt;/li&gt;
&lt;li&gt;The geospatial team at &lt;a href="http://www.doc.govt.nz/"&gt;Department of Conservation&lt;/a&gt; in Wellington.&lt;/li&gt;
&lt;li&gt;Brent Wood and Kevin Mackay at &lt;a href="http://www.niwa.co.nz/"&gt;NIWA&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.newtopo.co.nz/"&gt;NewTopo&lt;/a&gt; (Geoff Aitken). &lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://earthatlas.info/nz/?layers=Tour" width="100%"&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
I've been a real map nerd in New Zealand, but I had lots of time to explore the country too. Here are a few of my photos:&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-mIJPKKwccW4/UJbFLjQdXkI/AAAAAAAAKm4/SKI8sKXVCGM/s1600/177394_10151100197666817_1690906663_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-mIJPKKwccW4/UJbFLjQdXkI/AAAAAAAAKm4/SKI8sKXVCGM/s640/177394_10151100197666817_1690906663_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-jRv6pYAY-MQ/UJbFO5yfNUI/AAAAAAAAKnQ/kaLpYWuW-ys/s1600/204475_10151080284096817_1613936626_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-jRv6pYAY-MQ/UJbFO5yfNUI/AAAAAAAAKnQ/kaLpYWuW-ys/s640/204475_10151080284096817_1613936626_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-I7qVkzJajk8/UJbFQWI_b3I/AAAAAAAAKnc/tIVZLV8NKqc/s1600/209668_10151073892401817_2091974013_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-I7qVkzJajk8/UJbFQWI_b3I/AAAAAAAAKnc/tIVZLV8NKqc/s640/209668_10151073892401817_2091974013_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-yoGVi5vc0r0/UJbFSwby3UI/AAAAAAAAKn0/1HEoc1KR5Zs/s1600/258091_10151073891116817_827161763_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-yoGVi5vc0r0/UJbFSwby3UI/AAAAAAAAKn0/1HEoc1KR5Zs/s640/258091_10151073891116817_827161763_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&amp;nbsp; &lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-xhntDAEc6P8/UJbFVrgNVHI/AAAAAAAAKoQ/lc4EDb5smys/s1600/286195_10151089072376817_207930063_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-xhntDAEc6P8/UJbFVrgNVHI/AAAAAAAAKoQ/lc4EDb5smys/s640/286195_10151089072376817_207930063_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-Crzhzmc22ws/UJbFX43GzjI/AAAAAAAAKok/V3JpXRZKMSA/s1600/415135_10151039598316817_1968706694_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-Crzhzmc22ws/UJbFX43GzjI/AAAAAAAAKok/V3JpXRZKMSA/s640/415135_10151039598316817_1968706694_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-W5oh7wrLODk/UJbFYdmBHoI/AAAAAAAAKos/criqE1_pJ9o/s1600/416343_10151039598731817_692307415_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-W5oh7wrLODk/UJbFYdmBHoI/AAAAAAAAKos/criqE1_pJ9o/s640/416343_10151039598731817_692307415_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-MT5i7lJo1zI/UJbFaJ-3RHI/AAAAAAAAKpA/-NZB52lzWww/s1600/51825_10151077825336817_1262520805_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-MT5i7lJo1zI/UJbFaJ-3RHI/AAAAAAAAKpA/-NZB52lzWww/s640/51825_10151077825336817_1262520805_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-k6RywxwVfbQ/UJbFbFr2hnI/AAAAAAAAKpE/ZZn7fd0BRH0/s1600/53469_10151085371991817_1897866409_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-k6RywxwVfbQ/UJbFbFr2hnI/AAAAAAAAKpE/ZZn7fd0BRH0/s640/53469_10151085371991817_1897866409_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-BJB3QSDqRSs/UJbFcrZQwYI/AAAAAAAAKpY/pMYWAQbOA4I/s1600/614950_10151085332281817_1570263933_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-BJB3QSDqRSs/UJbFcrZQwYI/AAAAAAAAKpY/pMYWAQbOA4I/s640/614950_10151085332281817_1570263933_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-lslTFJCugEY/UJbFdxg8tbI/AAAAAAAAKpc/Tg0rV7qSXWk/s1600/615093_10151080283156817_2055978393_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-lslTFJCugEY/UJbFdxg8tbI/AAAAAAAAKpc/Tg0rV7qSXWk/s640/615093_10151080283156817_2055978393_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-x19spkSmPMQ/UJbFeRolCxI/AAAAAAAAKpo/osKLmrkMows/s1600/615404_10151092737576817_555667517_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-x19spkSmPMQ/UJbFeRolCxI/AAAAAAAAKpo/osKLmrkMows/s640/615404_10151092737576817_555667517_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-Kzn2TdqAijs/UJbFfTjjgcI/AAAAAAAAKpw/FE2LUtGQ92s/s1600/615790_10151045863436817_1046665303_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-Kzn2TdqAijs/UJbFfTjjgcI/AAAAAAAAKpw/FE2LUtGQ92s/s640/615790_10151045863436817_1046665303_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-LTRMZl83cmw/UJbFgWB-sNI/AAAAAAAAKp0/w589F0HUZzo/s1600/615823_10151085372151817_1768450260_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-LTRMZl83cmw/UJbFgWB-sNI/AAAAAAAAKp0/w589F0HUZzo/s640/615823_10151085372151817_1768450260_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-gK3EPmPBClM/UJbFj7nfafI/AAAAAAAAKqY/X_Ay4QhsqJg/s1600/664344_10151099148756817_421062092_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-gK3EPmPBClM/UJbFj7nfafI/AAAAAAAAKqY/X_Ay4QhsqJg/s640/664344_10151099148756817_421062092_o.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/7qrL5PX1-lo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/1377882018285501347/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=1377882018285501347" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/1377882018285501347?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/1377882018285501347?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/7qrL5PX1-lo/mapping-new-zealand-summary.html" title="Mapping New Zealand - a summary" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-oexDp-J8XwI/UJbOBtDe8rI/AAAAAAAAKrM/nVowvns1I3w/s72-c/P1060436.JPG" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/11/mapping-new-zealand-summary.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8GQHo7fCp7ImA9WhNREEg.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-1030738704615383537</id><published>2012-11-04T18:12:00.003Z</published><updated>2012-11-04T18:30:21.404Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T18:30:21.404Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Leaflet" /><title>New Leaflet plugin to handle multiple TileMill layers</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;a href="http://blog.thematicmapping.org/2012/10/mapping-population-density-of-new.html"&gt;My setup&lt;/a&gt; for the population density map of New Zealand made it easy to create new choropleth maps with New Zealand census data. This blog post explains how you can use Leaflet to switch between multiple interactive layers created with TileMill.&lt;br /&gt;
&lt;br /&gt;
I wanted to create a map of the social geography of New Zealand, using the &lt;a href="http://www.health.govt.nz/publication/nzdep2006-index-deprivation"&gt;Index of Deprivation&lt;/a&gt; from the Department of Public Health, University of Otago. I downloaded a Excel sheet containing data for the 2006 census area units, &lt;a href="http://blog.thematicmapping.org/2012/10/mapping-population-density-of-new.html"&gt;which I also used&lt;/a&gt; for my population density map. I simply added the data to the same SQLite database, and created the map using the same techniques described in two previous blog posts (&lt;a href="http://blog.thematicmapping.org/2012/10/mapping-population-density-of-new.html"&gt;1&lt;/a&gt;, &lt;a href="http://blog.thematicmapping.org/2012/11/exploring-mapbox-stack-mbtiles-tilejson.html"&gt;2&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-vC64CKIlLR8/UJanlZAoBGI/AAAAAAAAKlA/UqS9-msXSbI/s1600/deprivation.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-vC64CKIlLR8/UJanlZAoBGI/AAAAAAAAKlA/UqS9-msXSbI/s1600/deprivation.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;The Index of Deprivation is constructed from nine Census 2006 variables, and provides a summary deprivation score from 1 to 10. A score of 1 is allocated to the least deprived 10 percent of areas, and 10 is allocated to the most deprived 10 percent of areas. You'll find more information about the index in the &lt;a href="http://www.health.govt.nz/publication/dhb-maps-and-background-information-atlas-socioeconomic-deprivation-new-zealand-nzdep2006"&gt;Atlas of Socioeconomic Deprivation in New Zealand&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://mapbox.com/wax/"&gt;Wax&lt;/a&gt; allows you to easily add an interactive TileMill map to Leaflet or other mapping libraries. Adding more than one interactive layer is not that straightforward, so I wrote a Leaflet plugin:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/4012740.js?file=L.Wax.js"&gt;&lt;/script&gt;
&lt;br /&gt;
This plugin allows you to switch between various layers (interactive or not) and it will automatically load and display map legends, and remove the elements when they're no longer needed. It's easy to use the plugin:&lt;br /&gt;
&lt;br /&gt;
Include a wax property when you create a tile layer, containing a TileJSON object or an URL to a TileJSON file. &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;var population = L.tileLayer('tiles/nz-popden/{z}/{x}/{y}.png', {&lt;br /&gt;&amp;nbsp; attribution: '&lt;a href="http://www.stats.govt.nz/"&gt;Statistics New Zealand&lt;/a&gt;',&lt;br /&gt;&amp;nbsp; wax: 'tiles/nz-popden.tilejson'&lt;br /&gt;});&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
After you've created the map you simply add:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;L.wax(map);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
That's it! :-)&lt;br /&gt;
&lt;br /&gt;
You can try to switch between the various basemaps using the layers control below: &lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://earthatlas.info/nz/?base=Deprivation&amp;layers=Labels&amp;lat=-36.885&amp;lng=174.759&amp;zoom=11" width="100%"&gt;&lt;/iframe&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;a href="http://earthatlas.info/nz/?base=Deprivation&amp;layers=Labels&amp;lat=-36.885&amp;lng=174.759&amp;zoom=11"&gt;Fullscreen map&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/o2xwYp7RWmU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/1030738704615383537/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=1030738704615383537" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/1030738704615383537?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/1030738704615383537?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/o2xwYp7RWmU/new-leaflet-plugin-to-handle-multiple.html" title="New Leaflet plugin to handle multiple TileMill layers" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-vC64CKIlLR8/UJanlZAoBGI/AAAAAAAAKlA/UqS9-msXSbI/s72-c/deprivation.png" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/11/new-leaflet-plugin-to-handle-multiple.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8FRX8zcSp7ImA9WhNREEk.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-875120442300493528</id><published>2012-11-04T16:40:00.002Z</published><updated>2012-11-04T16:50:14.189Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T16:50:14.189Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="TileMill" /><title>Creating map labels with TileMill</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
It's one obvious thing missing from my maps of New Zealand: &lt;a href="http://en.wikipedia.org/wiki/Labeling_(map_design)"&gt;map labels&lt;/a&gt;. This blog post will show you how to create a transparant layer with map labels with &lt;a href="http://mapbox.com/tilemill/"&gt;TileMill&lt;/a&gt;, which can be added as an map overlay in Leaflet or other mapping libraries.&lt;br /&gt;
&lt;br /&gt;
To create map labels, you need a point dataset containg at least a position and the label text. As we'll see later, information about type of place, importance etc. will also be useful. For my New Zealand maps, I'm using a dataset from LINZ Data Service: &lt;a href="http://data.linz.govt.nz/#/layer/208-nz-geographic-names-topo-1500k/"&gt;NZ Geographic Names (Topo, 1:500k) &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I started by using &lt;a href="http://www.qgis.org/"&gt;QGIS&lt;/a&gt; to convert the shapefile into SQLite database (by right-clicking on the layer name in QGIS and select “Save as…”). This allows us run SQL queries against the data in TileMill. The dataset includes three attributes or columns, - name, size and a code describing the type of place:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-ufLOawarPEQ/UJaH9bLXEXI/AAAAAAAAKkA/njqRF2HeQY4/s1600/labelcols.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-ufLOawarPEQ/UJaH9bLXEXI/AAAAAAAAKkA/njqRF2HeQY4/s1600/labelcols.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I'm opening the SQLite file in TileMill: &lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-Sabx7oyPwhE/UJaJFvTR6kI/AAAAAAAAKkI/1NPV2ZkqZf4/s1600/sqlitetilemill.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="506" src="http://3.bp.blogspot.com/-Sabx7oyPwhE/UJaJFvTR6kI/AAAAAAAAKkI/1NPV2ZkqZf4/s640/sqlitetilemill.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;I'm using this SQL query to load the data from the SQLite database:&amp;nbsp;&lt;/span&gt;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;SELECT * FROM nz_labels ORDER BY size DESC&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This will sort the labels after size, in descending order. I'm assuming that larger size means more important labels, and this will instruct TileMill to start with the most important labels (there is not enough space to show all labels on all zoom levels). Remember also to include the SRS projection string for the data source (&lt;a href="http://www.linz.govt.nz/geodetic/datums-projections-heights/projections/new-zealand-transverse-mercator-2000"&gt;NZTM2000&lt;/a&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://mapbox.com/tilemill/docs/manual/carto/"&gt;CartoCSS&lt;/a&gt; includes a provides &lt;a href="http://mapbox.com/carto/api/2.1.0/#text"&gt;several ways&lt;/a&gt; to style map labels or text, and I haven't got the time to explore all the possibilities. This is the my CartoCSS for zoom level 5-7:&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/4012331.js?file=labels.mss"&gt;&lt;/script&gt;

I start by defining the fonts I'm going to use. It's a convention in cartography to label water features (lakes, sea, rivers) in serif italic faces, but small serif fonts on screen can be hard to read.. New high resolution screens, like Apple's Retina display, will probably make serif fonts more popular for web maps. You can use &lt;a href="http://www.typebrewer.org/typebrewer.html"&gt;TypeBrewer&lt;/a&gt; to test various font combinations. &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
I'm starting with the places marked as "METR" (probably &lt;a href="http://en.wikipedia.org/wiki/Metropolitan_area"&gt;metropolitan areas&lt;/a&gt;, although using this term in New Zealand sounds a bit strange...). I'm aligning the labels (&lt;a href="http://mapbox.com/carto/api/2.1.0/#text-horizontal-alignment"&gt;text-horizontal-alignment&lt;/a&gt;) to place them over the ocean, so they're not obscuring the map. A halo is added around the labels (&lt;a href="http://mapbox.com/carto/api/2.1.0/#text-halo-fill"&gt;text-halo-fill&lt;/a&gt; / &lt;a href="http://mapbox.com/carto/api/2.1.0/#text-halo-radius"&gt;text-halo-radius&lt;/a&gt;) to make the text visible on top of various basemaps.&lt;br /&gt;
&lt;br /&gt;
Auckland, Wellington, Christchurch and Dunedin are the only labels shown on zoom level 5 (in the Web Mercator projection). I'm then adding towns on zoom level 6, and populated places on zoom level 7.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-kLrOpKyXlN0/UJaX-ZwpnUI/AAAAAAAAKkk/Nxwv_0xSNOQ/s1600/labels-zoom6.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-kLrOpKyXlN0/UJaX-ZwpnUI/AAAAAAAAKkk/Nxwv_0xSNOQ/s1600/labels-zoom6.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Labels shown on zoom level 6.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
The minimum distance between each label (text-min-distance) is 30 pixels to avoid label collisions. This means that many towns or populated places will not be drawn because it's not enough space. More labels will be revealed as you zoom in. Although I sorted the features after the size attribute, it's probably not enough to make a good selection of labels for each zoom level. I'm sorry if I left out your town! :-)&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
I'm continuing like this until zoom level 12, gradually adding more labels for features like suburbs, lakes, mountains etc.&lt;br /&gt;
&lt;br /&gt;
The map labels were exported as a separate map using the MBTiles format, and added to my Leaflet map as a map overlay. This is the result:&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://earthatlas.info/nz/?base=Population&amp;amp;layers=Labels" width="100%"&gt;&lt;/iframe&gt;

&lt;a href="http://earthatlas.info/nz/?base=Population&amp;amp;layers=Labels"&gt;Fullscreen map&lt;/a&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/AePLI-apDbQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/875120442300493528/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=875120442300493528" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/875120442300493528?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/875120442300493528?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/AePLI-apDbQ/creating-labels-with-tilemill.html" title="Creating map labels with TileMill" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-ufLOawarPEQ/UJaH9bLXEXI/AAAAAAAAKkA/njqRF2HeQY4/s72-c/labelcols.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/11/creating-labels-with-tilemill.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0EMQHYzfyp7ImA9WhNREE4.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-1030685690355878836</id><published>2012-11-04T12:51:00.001Z</published><updated>2012-11-04T14:34:41.887Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T14:34:41.887Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="TileMill" /><category scheme="http://www.blogger.com/atom/ns#" term="Leaflet" /><category scheme="http://www.blogger.com/atom/ns#" term="MapBox" /><category scheme="http://www.blogger.com/atom/ns#" term="MBTiles" /><title>Exploring the MapBox stack: MBTiles, TileJSON, UTFGrids and Wax</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In &lt;a href="http://blog.thematicmapping.org/2012/10/mapping-population-density-of-new.html"&gt;my last blog post&lt;/a&gt;, we created a population density map of New Zealand using QGIS, SQLite and TileMill. Today, we’re going to publish this map to the web using various MapBox inventions. I'll also show you how to publish an interactive TileMill map on your own web server using some PHP and JavaScript wizardry.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
I love &lt;a href="http://mapbox.com/"&gt;MapBox&lt;/a&gt;. The team behind this platform has created a series of new specifications, allowing us to create fast, good looking and interactive maps. The downside is the &lt;a href="http://support.mapbox.com/discussions/tilemill/122-projection-support-wanted"&gt;limited support for other map projections&lt;/a&gt; than Web Mercator.&lt;br /&gt;
&lt;br /&gt;
TileMill allows you to add &lt;a href="http://mapbox.com/tilemill/docs/crashcourse/tooltips/"&gt;legends and tooltips&lt;/a&gt; to your maps. I’ve added a legend to &lt;a href="http://blog.thematicmapping.org/2012/10/mapping-population-density-of-new.html"&gt;my population density map&lt;/a&gt; with a HTML snippet describing the map and the color scale. &lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/4004891.js?file=legend.html"&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-ktZNx7SgIiw/UJRNSgI37PI/AAAAAAAAKi4/Dx_05B8ucVE/s1600/legend.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-ktZNx7SgIiw/UJRNSgI37PI/AAAAAAAAKi4/Dx_05B8ucVE/s1600/legend.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The tooltip shows when the user hovers over or clicks on the map. It allows us to show dynamic content - additional data, images, charts - for each map feature. I want to show the name, total population, area and population density for each feature: &lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/4011737.js?file=tooltip.tpl"&gt;&lt;/script&gt;

The data fields for the layer are wrapped in curly &lt;a href="http://mustache.github.com/"&gt;Mustache&lt;/a&gt; tags. These tags will be replaced by data when you interact with the map. You can use the full &lt;a href="http://mustache.github.com/mustache.5.html"&gt;Mustache template language&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-kIYwXVrmWWs/UJRQudZyoPI/AAAAAAAAKjU/XcC3Fq8g9lI/s1600/tooltip.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-kIYwXVrmWWs/UJRQudZyoPI/AAAAAAAAKjU/XcC3Fq8g9lI/s1600/tooltip.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The easy way to publish this map is to upload it to &lt;a href="http://tiles.mapbox.com/"&gt;MapBox Hosting&lt;/a&gt;, and use the embed code provided. If you want to publish your map on your own web server, this is an alternative route:&lt;br /&gt;
&lt;br /&gt;
To export an interactive map from TileMill, you need to use the &lt;a href="http://mapbox.com/developers/mbtiles/"&gt;MBTiles format&lt;/a&gt;. This is an innovative &lt;a href="http://www.sqlite.org/"&gt;SQLite-based&lt;/a&gt; format specification capable of storing millions of map tiles in a single file. The format is also supported by various &lt;a href="https://github.com/mapbox/mbtiles-spec/wiki/Implementations"&gt;3rd-party applications&lt;/a&gt;, and I'm sure we'll see a greater adoption in the future. &lt;br /&gt;
&lt;br /&gt;
Within the MBTiles file, the map legend, the tooltip template and information about map extent, zoom levels etc. is stored in a format named &lt;a href="http://mapbox.com/developers/tilejson/"&gt;TileJSON&lt;/a&gt;. This is also an &lt;a href="https://github.com/mapbox/tilejson-spec"&gt;open specification&lt;/a&gt;, providing a consistent way of describing a map, making it easier to load and display a map the way it’s meant to be seen.&amp;nbsp; The TileJSON for my map looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/4011766.js?file=nz-popden.tilejson"&gt;&lt;/script&gt;

If you add interactivity to your map (tooltips), your MBTiles file will also include the most impressing part of the MapBox specifications: &lt;a href="http://mapbox.com/developers/utfgrid/"&gt;UTFgrids&lt;/a&gt;. This JSON-format allows us to add thousands of interactive points or polygons through &lt;a href="http://mapbox.com/blog/how-interactivity-works-utfgrid/"&gt;interactivity data grids&lt;/a&gt;, and it will even work in older browsers with limited support for vector data.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
So how do we turn our MBTiles file into an interactive map? &lt;a href="http://blog.thematicmapping.org/2012/09/mapping-new-zealand-extracting-tiles.html"&gt;Previously&lt;/a&gt;, I've used MBUtil to extract the contents from MBTiles into a directory structure. But by doing this, we loose the benefits of the MBTiles format, like storing a map in a single file and &lt;a href="http://mapbox.com/developers/mbtiles/#using_views_to_reference_redundant_images"&gt;dealing with redundant images&lt;/a&gt;. What we need is a script on our web server that will extract content from our MBTiles file on demand. I decided to try &lt;a href="https://github.com/infostreams/mbtiles-php/"&gt;a PHP script from infostreams&lt;/a&gt; (this is probably not the most scaleable solution). The script supports the full MBTiles specification, including TileJSON and UTFGrids. Installation is simple: just put the .php file and the .htaccess file in the same directory as your .mbtiles files. The .htaccess file includes a rule that rewrites requested URLs on the fly, so the map data is available un URLs like:&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;TileJSON: &lt;a href="http://earthatlas.info/nz/tiles/nz-popden.tilejson"&gt;http://earthatlas.info/nz/tiles/nz-popden.tilejson&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Map tile: &lt;a href="http://earthatlas.info/nz/tiles/nz-popden/9/504/320.png"&gt;http://earthatlas.info/nz/tiles/nz-popden/9/504/320.png&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;UTFGrid: &lt;a href="http://earthatlas.info/nz/tiles/nz-popden/9/504/320.json"&gt;http://earthatlas.info/nz/tiles/nz-popden/9/504/320.json&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;
So when we have our backend sorted, how can we recreate our interactive map with Leaflet or other JavaScript mapping libraries? This is way the MapBox team created &lt;a href="http://mapbox.com/wax/"&gt;Wax&lt;/a&gt;, which is a client implementation of the MBTiles interaction specification. You just include the wax script together with your mapping library of choice, and then you can add interactivity with a few lines of code:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/4011779.js?file=leaflet-wax.js"&gt;&lt;/script&gt;

I've also done some extra JavaScript coding to allow switching between various interactive map layers. I'll save that for a later blog post.&lt;br /&gt;
&lt;br /&gt;
The Leaflet map looks like this (&lt;a href="https://github.com/mapbox/wax/issues/242"&gt;there seems to be an issue with the latest Wax distribution and Google Chrome&lt;/a&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://earthatlas.info/nz/?base=Population" width="100%"&gt;&lt;/iframe&gt;

&lt;a href="http://earthatlas.info/nz/?base=Population"&gt;Fullscreen map&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/aS2ukWHK5jE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/1030685690355878836/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=1030685690355878836" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/1030685690355878836?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/1030685690355878836?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/aS2ukWHK5jE/exploring-mapbox-stack-mbtiles-tilejson.html" title="Exploring the MapBox stack: MBTiles, TileJSON, UTFGrids and Wax" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-ktZNx7SgIiw/UJRNSgI37PI/AAAAAAAAKi4/Dx_05B8ucVE/s72-c/legend.png" height="72" width="72" /><thr:total>7</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/11/exploring-mapbox-stack-mbtiles-tilejson.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QHRXkyeyp7ImA9WhNREE4.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-1293933649242575422</id><published>2012-10-26T11:58:00.002+01:00</published><updated>2012-11-04T14:28:54.793Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T14:28:54.793Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="TileMill" /><category scheme="http://www.blogger.com/atom/ns#" term="QGIS" /><title>Mapping the population density of New Zealand with QGIS, SQLite and TileMill</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
There are over &lt;a href="http://www.stats.govt.nz/tools_and_services/tools/population_clock.aspx"&gt;4.4 million people&lt;/a&gt; living in New Zealand, but they’re not evenly distributed across the country. On my travels, I’ve been to some very remote areas like &lt;a href="http://en.wikipedia.org/wiki/Doubtful_Sound"&gt;Doubtful Sound&lt;/a&gt; in Fjordland with a permanent population of one! Where do the New Zealanders live? Let’s create a population density map of New Zealand.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-JRvjqCZnNaw/UIpwrudv8yI/AAAAAAAAKiY/DeZUwSDU5T0/s1600/P1050646.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-JRvjqCZnNaw/UIpwrudv8yI/AAAAAAAAKiY/DeZUwSDU5T0/s640/P1050646.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Doubtful Sound&lt;span style="color: #222222;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
According to &lt;a href="http://shop.lonelyplanet.com/new-zealand/new-zealand-16/"&gt;Lonely Planet&lt;/a&gt;, 63% of New Zealanders live on the North Island, 20% on the South Island, 10% in Australia, 5% in the rest of the world, and 2% are travelling! The area of New Zealand is 268,021 km2 (Norway has 385,252 km2), which means there are about 16.5 New Zealanders per km2. Norwegians have a bit more space, we're &lt;i&gt;only&lt;/i&gt; 15.5 persons per km2.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-2VSzYKTW8Qg/UIpwpP0f98I/AAAAAAAAKiQ/RSCRcd3WI-Y/s1600/P1030805.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-2VSzYKTW8Qg/UIpwpP0f98I/AAAAAAAAKiQ/RSCRcd3WI-Y/s640/P1030805.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Auckland&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
I want to map the population density as a &lt;a href="http://en.wikipedia.org/wiki/Choropleth_map"&gt;choropleth map&lt;/a&gt;, using darker colors for higher densities. But which units or geographical areas should I use? The regions (territorial authorities) I mapped in &lt;a href="http://blog.thematicmapping.org/2012/10/mapping-regions-of-new-zealand-with.html"&gt;my last blog post&lt;/a&gt; are too big to show the population density of the country. Instead, I decided to use &lt;a href="http://www.stats.govt.nz/Census/about-2006-census/2006-census-definitions-questionnaires/definitions/geographic.aspx"&gt;area units&lt;/a&gt;, which are non-administrative areas that are in between meshblocks (the smallest geographic unit for which statistical data is collected by Statistics New Zealand) and territorial authorities. In urban areas, area units normally contain a population of 3,000–5,000.&lt;br /&gt;
&lt;br /&gt;
The &lt;a href="http://www.stats.govt.nz/Census.aspx"&gt;census&lt;/a&gt; is the official count of how many people and dwellings there are in New Zealand. It takes a snapshot of the people in New Zealand and the places where we live. The last census was in 2006. There was supposed to be a new census in 2011, but it could not be completed due the national state of emergency after the Christchurch earthquake. A new census is scheduled for 2013. &lt;br /&gt;
&lt;br /&gt;
I therefore decided to download the area units used for 2006 census. These can be found on &lt;a href="http://koordinates.com/#/layer/1245-nz-area-units-2006-census/"&gt;Koordinates.com&lt;/a&gt;. I used &lt;a href="http://www.qgis.org/"&gt;QGIS&lt;/a&gt; to removed ocean, lakes, inlets and tidal bay areas where no or very few people live – which gives me the shape of New Zealand the people recognize.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-xGkIAlY5HjY/UIpgXFxfy6I/AAAAAAAAKgA/PTuVW_s2MbQ/s1600/qgis_area_units.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-xGkIAlY5HjY/UIpgXFxfy6I/AAAAAAAAKgA/PTuVW_s2MbQ/s1600/qgis_area_units.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The yellow area shows the extent of the original dataset, while the red color shows the area units after removing osean, lakes, inlets and tidal bay areas. &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
I’ve also used the field calculator in QGIS to calculate the size (in square kilometers) of each area unit polygon. &lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-lgVUUvXefPk/UIphH7O6xnI/AAAAAAAAKgI/HNWyQr59vNo/s1600/qgis_field_calculator.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="379" src="http://3.bp.blogspot.com/-lgVUUvXefPk/UIphH7O6xnI/AAAAAAAAKgI/HNWyQr59vNo/s400/qgis_field_calculator.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The dataset is in the &lt;a href="http://www.linz.govt.nz/geodetic/datums-projections-heights/projections/new-zealand-transverse-mercator-2000"&gt;New Zealand Transverse Mercator 2000 (NZTM2000)&lt;/a&gt; projection, which is using a metric coordinate system. The formula to calculate the area in km2 is $area / 1,000,000. There are one million square meters in a square kilometer.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-zc0WZfjGsZM/UIphpcjjLTI/AAAAAAAAKgQ/4CPunZJc1ng/s1600/qgis_biggest_areas.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-zc0WZfjGsZM/UIphpcjjLTI/AAAAAAAAKgQ/4CPunZJc1ng/s1600/qgis_biggest_areas.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The largest area unit is Fjordland with 8287 km2. The smallest area unit is &lt;br /&gt;
Motuopae Island in Tauranga, with less than 0.03 km2. &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
We can save the dataset as a &lt;a href="http://www.sqlite.org/"&gt;SQLite&lt;/a&gt; database by right-clicking on the layer name in QGIS and select “Save as…”.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-oFrCwpV7NA0/UIpiCcSpaBI/AAAAAAAAKgY/zkwVCKxgRAc/s1600/qgis_sqlite.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-oFrCwpV7NA0/UIpiCcSpaBI/AAAAAAAAKgY/zkwVCKxgRAc/s1600/qgis_sqlite.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Using SQLite will allow us to add the population data to the same file. &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Now that we have the area units, we need some population data covering the same geographical areas. Luckily, getting statistical data in New Zealand is as easy as &lt;a href="http://blog.thematicmapping.org/2012/09/getting-free-data-in-new-zealand.html"&gt;getting geospatial data&lt;/a&gt;. I used the &lt;a href="http://www.stats.govt.nz/tools_and_services/tools/nzdotstat.aspx"&gt;beta release&lt;/a&gt; of &lt;a href="http://nzdotstat.stats.govt.nz/wbos/Index.aspx"&gt;NZ.Stat&lt;/a&gt; to download estimated population data for 2006-2011.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-i-id_lNKesc/UIpj5l3gfuI/AAAAAAAAKgg/sA3jTeiFuvU/s1600/nz_stat_pop.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="478" src="http://1.bp.blogspot.com/-i-id_lNKesc/UIpj5l3gfuI/AAAAAAAAKgg/sA3jTeiFuvU/s640/nz_stat_pop.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
It was not possible to download the dataset as a CSV file when I tried, so I downloaded the Excel version. I then created a CSV file with this format (first line is the column names):&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;no;name;pop2006;pop2007;pop2008;pop2009;pop2010;pop2011&lt;br /&gt;500100;Awanui;370;360;360;360;360;360&lt;br /&gt;500202;Karikari Peninsula-Maungataniwha;4350;4320;4300;4320;4370;4350&lt;br /&gt;500203;Taipa Bay-Mangonui;1610;1590;1570;1560;1550;1540&lt;br /&gt;500204;Herekino;2020;2000;1980;1960;1960;1950&lt;br /&gt;500205;Ahipara;1160;1160;1180;1170;1170;1180&lt;br /&gt;500206;North Cape;520;500;490;480;460;450&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I used &lt;a href="http://sqlitebrowser.sourceforge.net/"&gt;SQLite Database Browser&lt;/a&gt; to import the population dataset to the file containing the area units (File -&amp;gt; Import -&amp;gt; Table from CSV file).&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-JaBQfyqlOQE/UIpke3-wWdI/AAAAAAAAKgo/nlh9b_7bUk0/s1600/sqlite_import.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-JaBQfyqlOQE/UIpke3-wWdI/AAAAAAAAKgo/nlh9b_7bUk0/s1600/sqlite_import.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, we can use &lt;a href="http://mapbox.com/tilemill/"&gt;TileMill&lt;/a&gt; to create population density map. You can create a layer from a SQLite database like this: &lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/--I_5lyD2e_w/UIplP2s-2QI/AAAAAAAAKgw/3gvygpQsul0/s1600/tilemill_sqlite.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="510" src="http://1.bp.blogspot.com/--I_5lyD2e_w/UIplP2s-2QI/AAAAAAAAKgw/3gvygpQsul0/s640/tilemill_sqlite.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
I'm using this SQL query to join the area units and the population data:&lt;br /&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:WordDocument&gt;
  &lt;w:View&gt;Normal&lt;/w:View&gt;
  &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
  &lt;w:TrackMoves/&gt;
  &lt;w:TrackFormatting/&gt;
  &lt;w:HyphenationZone&gt;21&lt;/w:HyphenationZone&gt;
  &lt;w:PunctuationKerning/&gt;
  &lt;w:ValidateAgainstSchemas/&gt;
  &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
  &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
  &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
  &lt;w:DoNotPromoteQF/&gt;
  &lt;w:LidThemeOther&gt;NO-BOK&lt;/w:LidThemeOther&gt;
  &lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt;
  &lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;
  &lt;w:Compatibility&gt;
   &lt;w:BreakWrappedTables/&gt;
   &lt;w:SnapToGridInCell/&gt;
   &lt;w:WrapTextWithPunct/&gt;
   &lt;w:UseAsianBreakRules/&gt;
   &lt;w:DontGrowAutofit/&gt;
   &lt;w:SplitPgBreakAndParaMark/&gt;
   &lt;w:EnableOpenTypeKerning/&gt;
   &lt;w:DontFlipMirrorIndents/&gt;
   &lt;w:OverrideTableStyleHps/&gt;
  &lt;/w:Compatibility&gt;
  &lt;m:mathPr&gt;
   &lt;m:mathFont m:val="Cambria Math"/&gt;
   &lt;m:brkBin m:val="before"/&gt;
   &lt;m:brkBinSub m:val="&amp;#45;-"/&gt;
   &lt;m:smallFrac m:val="off"/&gt;
   &lt;m:dispDef/&gt;
   &lt;m:lMargin m:val="0"/&gt;
   &lt;m:rMargin m:val="0"/&gt;
   &lt;m:defJc m:val="centerGroup"/&gt;
   &lt;m:wrapIndent m:val="1440"/&gt;
   &lt;m:intLim m:val="subSup"/&gt;
   &lt;m:naryLim m:val="undOvr"/&gt;
  &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
  DefSemiHidden="true" DefQFormat="false" DefPriority="99"
  LatentStyleCount="267"&gt;
  &lt;w:LsdException Locked="false" Priority="0" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Normal"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/&gt;
  &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 7"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 8"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" Name="toc 9"/&gt;
  &lt;w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/&gt;
  &lt;w:LsdException Locked="false" Priority="10" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Title"/&gt;
  &lt;w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/&gt;
  &lt;w:LsdException Locked="false" Priority="11" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/&gt;
  &lt;w:LsdException Locked="false" Priority="22" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Strong"/&gt;
  &lt;w:LsdException Locked="false" Priority="20" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/&gt;
  &lt;w:LsdException Locked="false" Priority="59" SemiHidden="false"
   UnhideWhenUsed="false" Name="Table Grid"/&gt;
  &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/&gt;
  &lt;w:LsdException Locked="false" Priority="1" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/&gt;
  &lt;w:LsdException Locked="false" Priority="34" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/&gt;
  &lt;w:LsdException Locked="false" Priority="29" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Quote"/&gt;
  &lt;w:LsdException Locked="false" Priority="30" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/&gt;
  &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/&gt;
  &lt;w:LsdException Locked="false" Priority="19" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/&gt;
  &lt;w:LsdException Locked="false" Priority="21" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/&gt;
  &lt;w:LsdException Locked="false" Priority="31" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/&gt;
  &lt;w:LsdException Locked="false" Priority="32" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/&gt;
  &lt;w:LsdException Locked="false" Priority="33" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Book Title"/&gt;
  &lt;w:LsdException Locked="false" Priority="37" Name="Bibliography"/&gt;
  &lt;w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/&gt;
 &lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:"Vanlig tabell";
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-priority:99;
 mso-style-parent:"";
 mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
 mso-para-margin:0cm;
 mso-para-margin-bottom:.0001pt;
 mso-pagination:widow-orphan;
 font-size:10.0pt;
 font-family:"Calibri","sans-serif";}
&lt;/style&gt;
&lt;![endif]--&gt;

&lt;br /&gt;
&lt;span lang="EN-US" style="background: white; color: #222222; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: NO-BOK;"&gt;&lt;br /&gt;SELECT OGC_FID, au_no, au_name, geometry, area,
pop2011, (pop2011/area) AS popdens FROM nz_area_units_2006_census AS area JOIN
population ON au_no = no&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The query is also calculating the population per km2 (pop2011/area), which will be our mapping variable. Also note that you need to specify the SRS projection string for the dataset (NZTM2000):&lt;span lang="EN-US" style="background: white; color: #222222; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10.0pt; line-height: 115%; mso-ansi-language: EN-US;"&gt;&lt;br /&gt;&lt;br /&gt;+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000
+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I've used a 9-class yellow-orange-brown color scheme from &lt;a href="http://colorbrewer2.org/"&gt;ColorBrewer&lt;/a&gt; to represent increasing population density. &lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-A6sbHsgZr7Y/UIpo7tuJ6eI/AAAAAAAAKhQ/XqLJGMJNC1w/s1600/colorbrewer.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="403" src="http://3.bp.blogspot.com/-A6sbHsgZr7Y/UIpo7tuJ6eI/AAAAAAAAKhQ/XqLJGMJNC1w/s640/colorbrewer.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This is my CartoCSS:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3958158.js?file=nz-popden.mss"&gt;&lt;/script&gt;

&lt;br /&gt;
The map looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-tyxwk9VxNtw/UIpsVvPBmiI/AAAAAAAAKhw/kluqkVuGSe4/s1600/nz-popden_b5d829.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://3.bp.blogspot.com/-tyxwk9VxNtw/UIpsVvPBmiI/AAAAAAAAKhw/kluqkVuGSe4/s640/nz-popden_b5d829.png" width="466" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #222222;"&gt;Recommended reading: &lt;a href="http://mapbox.com/tilemill/docs/tutorials/sqlite-work/"&gt;Working with TileMill and SQLite (MapBox)&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: inherit;"&gt;&lt;span style="color: #222222;"&gt;I'm going to create an interactive version with a map legend in my next blog post. Stay tuned! &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/5nzN7nUTdO8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/1293933649242575422/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=1293933649242575422" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/1293933649242575422?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/1293933649242575422?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/5nzN7nUTdO8/mapping-population-density-of-new.html" title="Mapping the population density of New Zealand with QGIS, SQLite and TileMill" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-JRvjqCZnNaw/UIpwrudv8yI/AAAAAAAAKiY/DeZUwSDU5T0/s72-c/P1050646.JPG" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/10/mapping-population-density-of-new.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QCSHs6fCp7ImA9WhNREE4.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-614050676723109635</id><published>2012-10-22T07:10:00.003+01:00</published><updated>2012-11-04T14:29:29.514Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T14:29:29.514Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Leaflet" /><title>Mapping the regions of New Zealand with MapShaper and Leaflet</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
There are &lt;a href="http://en.wikipedia.org/wiki/Regions_of_New_Zealand"&gt;16 regions of New Zealand&lt;/a&gt;, and during my trip I’ll be visiting 15 of them (I’m saving the &lt;a href="http://en.wikipedia.org/wiki/Taranaki_Region"&gt;Taranaki region&lt;/a&gt; for my next visit). This blog post shows how you can download and simplify region boundaries, and add them to a map as an interactive layer. &lt;br /&gt;
&lt;br /&gt;
The region is the top tier of local government in New Zealand. Eleven are governed by an elected regional council, while five are governed by &lt;a href="http://en.wikipedia.org/wiki/Territorial_authorities_of_New_Zealand"&gt;territorial authorities&lt;/a&gt; (the second tier of local government) which also perform the functions of a regional council. The current regions came about in 1989, when they replaced more than 700 boards which had been formed in the preceding century.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-sVQkudXQRjI/UIThhRkcCfI/AAAAAAAAKfU/RY_UAwpx_XM/s1600/boundary.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="442" src="http://1.bp.blogspot.com/-sVQkudXQRjI/UIThhRkcCfI/AAAAAAAAKfU/RY_UAwpx_XM/s640/boundary.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The geographic extents of the regions are largely based on &lt;a href="http://en.wikipedia.org/wiki/Drainage_basin"&gt;drainage basins&lt;/a&gt;, following drainage
 divides such as the Southern Alps.&amp;nbsp; &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
The dataset I’m using is from &lt;a href="http://www.stats.govt.nz/"&gt;Statistics New Zealand&lt;/a&gt;, the national statistical office. &lt;a href="http://koordinates.com/"&gt;Koordinates.com&lt;/a&gt; has made life easier by collecting &lt;a href="http://koordinates.com/maps/statsnz/"&gt;geographic data from Statistics New Zealand&lt;/a&gt; on their portal. I’ve downloaded &lt;a href="http://koordinates.com/maps/statsnz/#/layer/1244-nz-regional-councils-2006-census/"&gt;a polygon dataset&lt;/a&gt; from the &lt;a href="http://www.stats.govt.nz/Census.aspx"&gt;last census&lt;/a&gt; in New Zealand (2006).&lt;br /&gt;
&lt;br /&gt;
The dataset includes more than 60,000 coordinates used to draw the boundaries for each region. As I’m going to display the vector data directly in the web browser, I should simplify the dataset by reducing the number of coordinates while preserving the shape of the regions. Leaflet has &lt;a href="http://leaflet.cloudmade.com/features.html"&gt;built-in support&lt;/a&gt; for vector simplification (to make the map more responsive), but you shouldn’t rely on this alone as the data still has to be loaded and processed by Leaflet.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;br /&gt;
You can do vector simplification with QGIS (Vector -&amp;gt; Geometry Tools -&amp;gt; Simplify geometries), but there is a better tool, &lt;a href="http://mapshaper.org/"&gt;MapShaper&lt;/a&gt; (&lt;a href="http://www.cartogis.org/docs/proceedings/2006/bloch_harrower.pdf"&gt;about&lt;/a&gt;), which gives you more options and preserves topology (shared borders). I loaded the shapefile into MapShaper and set the simplification level to 50% using the Special &lt;a href="http://bost.ocks.org/mike/simplify/"&gt;Visvalingam method&lt;/a&gt;. This will reduce the number of coordinates by 90%, but you still have to zoom in very far to see the difference.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-rVOlfZl5VBo/UIThiRhVbqI/AAAAAAAAKfc/fPq9d49SqEc/s1600/mapshaper.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="417" src="http://1.bp.blogspot.com/-rVOlfZl5VBo/UIThiRhVbqI/AAAAAAAAKfc/fPq9d49SqEc/s640/mapshaper.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Next, I’m converting the simplified shapefile to GeoJSON with ogr2ogr:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ogr2ogr -t_srs EPSG:4326 -f "GeoJSON" -lco COORDINATE_PRECISION=3 nz-regional-councils-simplified.json nz-regional-councils-simplified.shp &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
By restricting the number of coordinates (COORDINATE_PRECISION=3) to the map scale or number of zoom levels, you can further reduce the size of the dataset. &lt;br /&gt;
&lt;br /&gt;
I’m assigning the GeoJSON object to a JavaScript variable (regions), and this is the code required to create a Leaflet layer with custom style, region highlighting and popups: &lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3929912.js?file=nz-regions.js"&gt;&lt;/script&gt;

The map looks like this: &lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600px" src="http://earthatlas.info/nz/?layers=Regions" width="100%"&gt;&lt;/iframe&gt;

&lt;a href="http://earthatlas.info/nz/?layers=Regions"&gt;Fullscreen map&lt;/a&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/_SN9Awo1GzU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/614050676723109635/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=614050676723109635" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/614050676723109635?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/614050676723109635?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/_SN9Awo1GzU/mapping-regions-of-new-zealand-with.html" title="Mapping the regions of New Zealand with MapShaper and Leaflet" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-sVQkudXQRjI/UIThhRkcCfI/AAAAAAAAKfU/RY_UAwpx_XM/s72-c/boundary.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/10/mapping-regions-of-new-zealand-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MESXs_fSp7ImA9WhNREE4.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-7385239938982226924</id><published>2012-10-20T10:53:00.001+01:00</published><updated>2012-11-04T14:30:08.545Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T14:30:08.545Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Leaflet" /><category scheme="http://www.blogger.com/atom/ns#" term="QGIS" /><title>Mapping New Zealand: Creating a road map</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
I’ve travelled around New Zealand by bus, car, boat, and by foot. In a &lt;a href="http://blog.thematicmapping.org/2012/10/mapping-new-zealand-using-leaflet-with.html"&gt;previous blog post&lt;/a&gt;, I created a “Where I’ve Been Map” using markers for each of the places I’ve stayed. Let’s add some lines showing the route between the markers. &lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-4vAyLeBhKhU/UIJviOysXQI/AAAAAAAAKeU/f9E6iRpDkrI/s1600/roads.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="434" src="http://3.bp.blogspot.com/-4vAyLeBhKhU/UIJviOysXQI/AAAAAAAAKeU/f9E6iRpDkrI/s640/roads.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;I've destroyed my National Geographic map while travelling around the New Zealand. How can I add the roads travelled to my digital map? &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-wPa-Df1wSE4/UIJ0BHO79_I/AAAAAAAAKe0/wjIBegd9q5I/s1600/P1050840.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-wPa-Df1wSE4/UIJ0BHO79_I/AAAAAAAAKe0/wjIBegd9q5I/s640/P1050840.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Travelling around New Zealand can be quite an experience. This is a well known sight. &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
I’ll concentrate on the roads in this post, and deal with boat and foot tracks later. As I didn’t carry a GPS when travelling by bus or car, I had to find the road lines from a different source. I’m using &lt;a href="http://data.linz.govt.nz/#/layer/184-nz-mainland-road-centrelines-topo-1250k/"&gt;road data from LINZ&lt;/a&gt; for my map, but I’m sure you can achieve the same with &lt;a href="http://www.openstreetmap.org/"&gt;OpenStreetMap&lt;/a&gt; data. &lt;br /&gt;
&lt;br /&gt;
First, I created an empty shapefile in &lt;a href="http://www.qgis.org/"&gt;QGIS&lt;/a&gt; for my road data. Then I marked and copied the roads I’ve travelled from the LINZ shapefile, and pasted the road segments into my own shapefile. I also had to cut road lines to remove parts where I’ve not been. Lastly, I merged the road segments together. QGIS is a great tool for tasks like this.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-BlzDSQhbfR4/UIJxbt4TPjI/AAAAAAAAKec/fvZna3go5EM/s1600/qgisroads.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="518" src="http://2.bp.blogspot.com/-BlzDSQhbfR4/UIJxbt4TPjI/AAAAAAAAKec/fvZna3go5EM/s640/qgisroads.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Editing road lines in QGIS.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
I used &lt;a href="http://www.gdal.org/ogr2ogr.html"&gt;ogr2ogr&lt;/a&gt; to convert the shapefile into GeoJSON, which is the vector format supported by Leaflet: &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ogr2ogr -t_srs EPSG:4326 -f "GeoJSON" -lco COORDINATE_PRECISION=3 nz-tour-road.json nz-tour-road.shp&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I then assigned the the GeoJSON object to a variable: &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;var roads = {&lt;br /&gt;&amp;nbsp; "type": "FeatureCollection",&lt;br /&gt;&amp;nbsp; "features": [...]&lt;br /&gt;};&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To create a GeoJSON layer with custom styles in Leaflet only requires a few lines of code:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;var roads = L.geoJson(roads, {&lt;br /&gt;&amp;nbsp; style: {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; color: '#333',&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; weight: 1.5,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; opacity: 1&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;});&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As I wanted to combine the road lines with the place markers I decided to use the Leaflet &lt;a href="http://leaflet.cloudmade.com/reference.html#layergroup"&gt;LayerGroup&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3922754.js?file=nz-tour.js"&gt;&lt;/script&gt;

This is my new “Where I’ve Been” map: &lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600px" src="http://earthatlas.info/nz/?layers=Tour" width="100%"&gt;&lt;/iframe&gt;

&lt;a href="http://earthatlas.info/nz/?layers=Tour"&gt;Fullscreen map&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-AxBT3d-9vxQ/UIJz9q4m2YI/AAAAAAAAKek/xkCUZAMAHv0/s1600/P1050665.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-AxBT3d-9vxQ/UIJz9q4m2YI/AAAAAAAAKek/xkCUZAMAHv0/s640/P1050665.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Kingston road along Lake Wakatipu.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-nfepp7-xCx0/UIJz_SMNjEI/AAAAAAAAKes/a1mfTSHJx68/s1600/P1050714.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-nfepp7-xCx0/UIJz_SMNjEI/AAAAAAAAKes/a1mfTSHJx68/s640/P1050714.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Towards Glenorchy and the Southern Alps.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/0htwp_epAqU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/7385239938982226924/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=7385239938982226924" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/7385239938982226924?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/7385239938982226924?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/0htwp_epAqU/mapping-new-zealand-creating-road-map.html" title="Mapping New Zealand: Creating a road map" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-4vAyLeBhKhU/UIJviOysXQI/AAAAAAAAKeU/f9E6iRpDkrI/s72-c/roads.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/10/mapping-new-zealand-creating-road-map.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MCSHg9eSp7ImA9WhNREE4.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-330171487942744104</id><published>2012-10-20T09:15:00.001+01:00</published><updated>2012-11-04T14:31:09.661Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T14:31:09.661Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Leaflet" /><category scheme="http://www.blogger.com/atom/ns#" term="OGR" /><title>Mapping New Zealand: Clustering DOC Huts with Leaflet</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In New Zealand, long distance walking or hiking for at least one overnight stay is known as &lt;a href="http://en.wikipedia.org/wiki/Tramping_in_New_Zealand"&gt;&lt;i&gt;tramping&lt;/i&gt;&lt;/a&gt;. There is a great network of over &lt;a href="http://www.doc.govt.nz/parks-and-recreation/places-to-stay/backcountry-hut-information/"&gt;950 huts&lt;/a&gt; throughout New Zealand operated by the &lt;a href="http://www.doc.govt.nz/"&gt;Department of Conservation&lt;/a&gt; (DOC). I’ve just stayed in four of the huts while tramping the &lt;a href="http://www.doc.govt.nz/parks-and-recreation/tracks-and-walks/nelson-tasman/golden-bay/abel-tasman-coast-track/"&gt;Abel Tasman Coast Track&lt;/a&gt;, and you need a lifetime to reach them all. It’s much quicker to map them.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-WzxgQHx2TXo/UIJbTVvZKcI/AAAAAAAAKd0/fXURwDLZF5Q/s1600/dochuts.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-WzxgQHx2TXo/UIJbTVvZKcI/AAAAAAAAKd0/fXURwDLZF5Q/s1600/dochuts.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;DOC huts in the &lt;a href="http://www.doc.govt.nz/parks-and-recreation/national-parks/abel-tasman/"&gt;Abel Tasman National Park&lt;/a&gt;. &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-dc3ePQhJRTs/UIJaa1t_g1I/AAAAAAAAKdk/y1RiAQq-BDM/s1600/P1040988.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-dc3ePQhJRTs/UIJaa1t_g1I/AAAAAAAAKdk/y1RiAQq-BDM/s640/P1040988.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;a href="http://www.doc.govt.nz/parks-and-recreation/places-to-stay/backcountry-huts-by-region/nelson-tasman/golden-bay/awaroa-hut/"&gt;Awaroa Hut&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
I was fortunate to visit the geospatial unit at the DOC office in Wellington. They have a lot of ineresting conservation projects going on, and it seemed to be a great place to work in New Zealand, especially when you can combine digital work with practical field work. &lt;br /&gt;
&lt;br /&gt;
You can download DOC's geospatial data for free on their &lt;a href="http://geoportal.doc.govt.nz/geoportal/catalog/main/home.page"&gt;data portal&lt;/a&gt;. Unfortunately, the datasets are not available as shapefiles, so it might require some wizardry to extract the data from KML. Luckily, the &lt;a href="http://koordinates.com/"&gt;Koordinates&lt;/a&gt; guys have done this already, and you can download the shapefile from &lt;a href="http://koordinates.com/layers/global/oceania/new-zealand/#/layer/3910-doc-huts/"&gt;their website&lt;/a&gt;. The version I’m using was updated 10 September 2012. &lt;br /&gt;
&lt;br /&gt;
The dataset contains 967 huts, and adding them all to my Leaflet map will make it too cluttered to be useful. Instead, I wanted to try the great &lt;a href="https://github.com/danzel/Leaflet.markercluster"&gt;animated marker clustering plugin&lt;/a&gt;, created by &lt;a href="https://twitter.com/daveleaver"&gt;Dave Leaver&lt;/a&gt; here in New Zealand. &lt;br /&gt;
&lt;br /&gt;
I start off by converting the shapefile to GeoJSON with &lt;a href="http://www.gdal.org/ogr2ogr.html"&gt;ogr2ogr&lt;/a&gt;: &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ogr2ogr -t_srs EPSG:4326 -f "GeoJSON" -lco COORDINATE_PRECISION=4 nz-doc-huts.json doc-huts.shp&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I could use the GeoJSON directly, but I converted it to a more compact format to save some bandwith: &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;var huts = [&lt;br /&gt;&amp;nbsp; [-43.3767,170.5685,"Scone Hut",1],&lt;br /&gt;&amp;nbsp; [-42.9494,171.7047,"Sudden Valley Biv",0],&lt;br /&gt;&amp;nbsp; [-41.5237,172.5604,"Granity Pass Hut",1],&lt;br /&gt;&amp;nbsp; [-44.9261,168.2144,"Steele Creek Hut",0],&lt;br /&gt;&amp;nbsp; [-44.6221,168.4481,"Earnslaw Hut",0],&lt;br /&gt;&amp;nbsp; [-45.3852,167.6192,"Luxmore Hut",4],&lt;br /&gt;&amp;nbsp; ...&lt;/span&gt;&lt;br /&gt;
];&lt;br /&gt;
&lt;br /&gt;
The last number corresponds to the &lt;a href="http://www.doc.govt.nz/parks-and-recreation/places-to-stay/backcountry-hut-information/hut-categories/"&gt;hut categories&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
0. Basic Hut/Bivvy&lt;br /&gt;
1. Standard Hut&lt;br /&gt;
2. Serviced Hut&lt;br /&gt;
3. Serviced-Alpine Hut&lt;br /&gt;
4. Great Walk Hut&lt;br /&gt;
&lt;br /&gt;
This is the code you need to create clustered huts with custom markers: &lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3922626.js?file=dochuts.js"&gt;&lt;/script&gt;

The JavaScript &lt;a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map"&gt;map function&lt;/a&gt;, which converts one array into another, is not supported in Internet Explorer 8 and lower. If you need to support prehistoric browsers, use a for-loop instead. The icons I’ve used (which could have been more descriptive) are from &lt;a href="http://mapicons.nicolasmollet.com/markers/friends-family/home/"&gt;Map Icons Collection&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The interactive map looks like this: &lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600px" src="http://earthatlas.info/nz/?layers=DOC%20Huts" width="100%"&gt;&lt;/iframe&gt;

&lt;a href="http://earthatlas.info/nz/?layers=DOC%20Huts"&gt;Fullscreen map&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
I especially like the animated feature of this clustering plugin (try zooming in and out), as it makes it more obvious for the map user what a cluster really is.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-oDm-b7vF_uw/UIJacn4-pmI/AAAAAAAAKds/ggT5buMWXWU/s1600/P1050157.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-oDm-b7vF_uw/UIJacn4-pmI/AAAAAAAAKds/ggT5buMWXWU/s640/P1050157.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;a href="http://www.doc.govt.nz/conservation/historic/by-region/nelson-tasman/golden-bay/whariwharangi-hut/"&gt;Whariwharangi Hut&lt;/a&gt;, built as a farmhouse in about 1896.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/AHJh_5xLLJI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/330171487942744104/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=330171487942744104" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/330171487942744104?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/330171487942744104?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/AHJh_5xLLJI/mapping-new-zealand-clustering-doc-huts.html" title="Mapping New Zealand: Clustering DOC Huts with Leaflet" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-WzxgQHx2TXo/UIJbTVvZKcI/AAAAAAAAKd0/fXURwDLZF5Q/s72-c/dochuts.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/10/mapping-new-zealand-clustering-doc-huts.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MNSXo9eCp7ImA9WhNREE4.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-4972990117843449121</id><published>2012-10-08T13:20:00.002+01:00</published><updated>2012-11-04T14:31:38.460Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T14:31:38.460Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Leaflet" /><category scheme="http://www.blogger.com/atom/ns#" term="OGR" /><title>Mapping New Zealand: Where are the hot and cold springs?</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
New Zealand has a large number of cold and &lt;a href="http://en.wikipedia.org/wiki/Hot_springs_in_New_Zealand"&gt;hot&lt;/a&gt; &lt;a href="http://en.wikipedia.org/wiki/Spring_(hydrology)"&gt;springs&lt;/a&gt;, where water flows to the surface of the earth from underground. Where can you find these springs? This blog post will show you can visualise a spring point dataset on a Leaflet map.&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-FIvini5OtXs/UHLEks9UffI/AAAAAAAAKcw/WyP9agvarfA/s1600/springs.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-FIvini5OtXs/UHLEks9UffI/AAAAAAAAKcw/WyP9agvarfA/s1600/springs.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
You can find &lt;a href="http://data.linz.govt.nz/#/layer/356-nz-mainland-spring-points-topo-150k/"&gt;spring point dataset&lt;/a&gt; at &lt;a href="http://data.linz.govt.nz/"&gt;LINZ Data Service&lt;/a&gt;, which contains 147 &lt;a href="http://apps.linz.govt.nz/topo-data-dictionary/index.aspx?page=class-spring_pnt"&gt;significant springs&lt;/a&gt; either by size or location. I downloaded the dataset as a shapefile, and converted it to &lt;a href="http://www.geojson.org/"&gt;GeoJSON&lt;/a&gt; using &lt;a href="http://www.gdal.org/ogr2ogr.html"&gt;ogr2ogr&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ogr2ogr -f "GeoJSON" -lco COORDINATE_PRECISION=4 nz-spring-points.json nz-spring-points-topo-150.shp&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The resulting GeoJSON &lt;a href="http://www.geojson.org/geojson-spec.html#feature-collection-objects"&gt;FeatureCollection&lt;/a&gt; can be assigned to a JavaScript variable:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;var springs = {"type":"FeatureCollection","features":[{...&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
... and visualised with Leaflet's &lt;a href="http://leaflet.cloudmade.com/reference.html#geojson"&gt;GeoJSON layer&lt;/a&gt; and &lt;a href="http://leaflet.cloudmade.com/reference.html#circlemarker"&gt;L.circleMarker&lt;/a&gt;&lt;span id="goog_1390562049"&gt;&lt;/span&gt;&lt;a href="http://draft.blogger.com/"&gt;&lt;/a&gt;&lt;span id="goog_1390562050"&gt;&lt;/span&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3852207.js?file=springs.js"&gt;&lt;/script&gt;

Here is the result:&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://earthatlas.info/nz/?layers=Springs" width="100%"&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;a href="http://earthatlas.info/nz/?layers=Springs"&gt;Fullscreen map&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-H8u3zF7uv_s/UHLGsmKqeqI/AAAAAAAAKdA/HbV8f4N-aic/s1600/P1050178.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-H8u3zF7uv_s/UHLGsmKqeqI/AAAAAAAAKdA/HbV8f4N-aic/s640/P1050178.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;a href="http://www.doc.govt.nz/parks-and-recreation/places-to-visit/nelson-tasman/golden-bay/te-waikoropupu-springs/"&gt;Te Waikoropupū Springs&lt;/a&gt; in Golden Bay, discharging 14,000 litres of water &lt;i&gt;per second&lt;/i&gt;, - the largest freshwater springs in New Zealand.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-6zpaH8xWri4/UHLGq0EuKxI/AAAAAAAAKc4/1L1EaJw8DXY/s1600/P1050177.JPG" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-6zpaH8xWri4/UHLGq0EuKxI/AAAAAAAAKc4/1L1EaJw8DXY/s640/P1050177.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The horizontal visibility of the water in the springs has been measured at an average of 63 metres, second only to sub-glacial water in the Antarctic.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/yC1o33fta2Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/4972990117843449121/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=4972990117843449121" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/4972990117843449121?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/4972990117843449121?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/yC1o33fta2Y/mapping-new-zealand-where-are-hot-and.html" title="Mapping New Zealand: Where are the hot and cold springs?" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-FIvini5OtXs/UHLEks9UffI/AAAAAAAAKcw/WyP9agvarfA/s72-c/springs.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/10/mapping-new-zealand-where-are-hot-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0ICR3ozfip7ImA9WhNREE4.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-7373357179115858363</id><published>2012-10-08T09:32:00.001+01:00</published><updated>2012-11-04T14:32:46.486Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T14:32:46.486Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Leaflet" /><title>How to control your Leaflet map with URL parameters</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-q5yTNDKJ5KE/UHKEx0_jfEI/AAAAAAAAKXw/OEdT8GGqsPE/s1600/leaflet.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-q5yTNDKJ5KE/UHKEx0_jfEI/AAAAAAAAKXw/OEdT8GGqsPE/s1600/leaflet.png" /&gt;&lt;/a&gt;&lt;/div&gt;
I needed a way to control the appearance for &lt;a href="http://earthatlas.info/nz/"&gt;my Leaflet map of New Zealand&lt;/a&gt;, especially when embedding a map with an iframe. Leaflet have no native support for URL parameters for, like the &lt;a href="http://dev.openlayers.org/docs/files/OpenLayers/Control/Permalink-js.html"&gt;Permalink control&lt;/a&gt; for OpenLayers (&lt;a href="https://github.com/shramov/leaflet-plugins"&gt;there is a plugin&lt;/a&gt; + &lt;a href="https://github.com/mlevans/leaflet-hash"&gt;Leaflet-hash&lt;/a&gt;). This blog post will show you how you can add support for URL parameters for map position (latitude/longitude), zoom level and active layers.&lt;br /&gt;
&lt;br /&gt;
First, I'm defining my layers in an JavaScript object:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;var layers = {&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; 'Seafloor': L.tileLayer('tiles/nz-seafloor/{z}/{x}/{y}.png'),&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; 'Topographic': L.tileLayer('tiles/nz-topo/{z}/{x}/{y}.png'),&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; 'Tour': L.cartoDB('http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT * FROM new_zealand_tour')&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;};&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
You can use the same object to populate the &lt;a href="http://leaflet.cloudmade.com/reference.html#control-layers"&gt;Leaflet layers control&lt;/a&gt;. Next, I'm extracting the URL parameters with a regular expression (&lt;a href="http://papermashup.com/read-url-get-variables-withjavascript/"&gt;from Papermashup&lt;/a&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;var params = {};&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;window.location.href.replace(/[?&amp;amp;]+([^=&amp;amp;]+)=([^&amp;amp;]*)/gi, function(m, key, value) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; params[key] = value;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;});&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
All URL parameters are now stored as key/value pairs in the params object. We need to create an array of active map layers: &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;if (params.layers) {&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; var activeLayers = params.layers.split(',').map(function(item) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return layers[item];&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; });&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The &lt;a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map"&gt;array map function&lt;/a&gt; will create a new array with a reference to the visible layers on the map. Please note that the map function is not supported in Internet Explorer &amp;lt; 9 (you can easily rewrite the function with a &lt;a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/for"&gt;for loop&lt;/a&gt; to support this browser).&lt;br /&gt;
&lt;br /&gt;
We can now create a map with our URL parameters:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;var map = new L.Map('map', {&lt;br /&gt;&amp;nbsp; center: [params.lat || -41.2728, params.lng || 173.2996], &lt;br /&gt;&amp;nbsp; minZoom: 4,&lt;br /&gt;&amp;nbsp; maxZoom: 12,&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp; zoom: params.zoom || 6,&lt;br /&gt;&amp;nbsp; layers: activeLayers || [layers.Seafloor, layers.Topographic]&lt;br /&gt;});&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I'm using the &lt;a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Logical_Operators"&gt;Logical OR (||) operator&lt;/a&gt; to add default values. Lastly, I'm adding my map layers to the layers control, allowing users to toggle the visibility:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;L.control.layers({}, layers).addTo(map);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This is the full example:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3851326.js?file=map.js"&gt;&lt;/script&gt;
We can now control the map med URL parameters like (the code in this example is changed to support base layers and overlays):&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://earthatlas.info/nz/?lat=-42.4&amp;amp;lng=168&amp;amp;zoom=8"&gt;http://earthatlas.info/nz/?lat=-42.4&amp;amp;lng=168&amp;amp;zoom=8&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://earthatlas.info/nz/?lat=-42.4&amp;amp;lng=168&amp;amp;zoom=8" width="100%"&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://earthatlas.info/nz/?lat=-39.296&amp;amp;lng=174.065&amp;amp;zoom=11&amp;amp;layers=Springs"&gt;http://earthatlas.info/nz/?lat=-39.296&amp;amp;lng=174.065&amp;amp;zoom=11&amp;amp;layers=Springs&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://earthatlas.info/nz/?lat=-39.296&amp;amp;lng=174.065&amp;amp;zoom=11&amp;amp;layers=Springs" width="100%"&gt;&lt;/iframe&gt;



&lt;br /&gt;
Easy peasy!&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/t2Dz16GLU0I" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/7373357179115858363/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=7373357179115858363" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/7373357179115858363?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/7373357179115858363?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/t2Dz16GLU0I/how-to-control-your-leaflet-map-with.html" title="How to control your Leaflet map with URL parameters" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-q5yTNDKJ5KE/UHKEx0_jfEI/AAAAAAAAKXw/OEdT8GGqsPE/s72-c/leaflet.png" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/10/how-to-control-your-leaflet-map-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMBSHs_eyp7ImA9WhNREEg.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-2099362100706567666</id><published>2012-10-08T02:09:00.003+01:00</published><updated>2012-11-04T18:40:59.543Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T18:40:59.543Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Leaflet" /><category scheme="http://www.blogger.com/atom/ns#" term="CartoDB" /><title>Creating a "Where I've Been" map with Leaflet and CartoDB</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I wanted to create a "Where I've Been" map of my trip around New Zealand. The map should be easy to update through a simple web interface. Previously, I've used &lt;a href="http://tables.googlelabs.com/"&gt;Google Fusion Tables&lt;/a&gt; for tasks like this. Now, I want to try &lt;a href="http://cartodb.com/"&gt;CartoDB&lt;/a&gt;, which is Google Fusion Tables &lt;a href="http://cartodb.com/tour"&gt;on steroids&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-P3Gi5K85mtI/UHIktQ9oj1I/AAAAAAAAKXQ/_kqPJe7JZSA/s1600/cartodb.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="580" src="http://4.bp.blogspot.com/-P3Gi5K85mtI/UHIktQ9oj1I/AAAAAAAAKXQ/_kqPJe7JZSA/s640/cartodb.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I used the CartoDB &lt;a href="http://cartodb.com/pricing"&gt;free plan&lt;/a&gt; to create a &lt;a href="https://thematicmapping.cartodb.com/tables/10389/public"&gt;simple table containg the name and location&lt;/a&gt; of the places I've been:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-rnLaiAwqHxM/UHKF-_fw_II/AAAAAAAAKX4/63uTCHk_ETs/s1600/cartodb3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="260" src="http://2.bp.blogspot.com/-rnLaiAwqHxM/UHKF-_fw_II/AAAAAAAAKX4/63uTCHk_ETs/s640/cartodb3.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
You can easily query your data with the HTTP-based &lt;a href="http://developers.cartodb.com/documentation/cartodb-apis.html#sql_api"&gt;SQL API&lt;/a&gt;: &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;a href="http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT%20*%20FROM%20nz_tour"&gt;http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT * FROM nz_tour&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This request will return all the data in the default CartoDB JSON-format. Add &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;format=geojson&lt;/span&gt;, if you want the data in the &lt;a href="http://www.geojson.org/"&gt;GeoJSON&lt;/a&gt; format &lt;a href="http://leaflet.cloudmade.com/examples/geojson.html"&gt;supported by Leaflet&lt;/a&gt;: &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;a href="http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT%20*%20FROM%20nz_tour&amp;amp;format=geojson"&gt;http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT * FROM nz_tour&amp;amp;format=geojson&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The SQL API also supports &lt;a href="http://en.wikipedia.org/wiki/JSONP"&gt;JSONP&lt;/a&gt;, allowing you to query your data directly from JavaScript in the web browser. Just add a callback parameter:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;a href="http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT%20*%20FROM%20nz_tour&amp;amp;format=geojson&amp;amp;callback=myFunction"&gt;http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT * FROM nz_tour&amp;amp;format=geojson&amp;amp;callback=myFunction&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Leaflet don't have native support for JSONP or CartoDB, but there are a few plugins around (&lt;a href="https://github.com/vizzuality/cartodb-leaflet"&gt;1&lt;/a&gt;, &lt;a href="http://geojason.info/leaflet-vector-layers/"&gt;2&lt;/a&gt;). It's also very easy to extend Leaflet with the functionality you want, so I decided to create a new CartoDB layer class by extending the &lt;a href="http://leaflet.cloudmade.com/reference.html#geojson"&gt;L.GeoJSON&lt;/a&gt; class:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3850185.js?file=L.CartoDB.js"&gt;&lt;/script&gt;

This class rewrites the initialize function and adds a JSONP function (you can also use a library like &lt;a href="http://api.jquery.com/jQuery.getJSON/"&gt;jQuery&lt;/a&gt;). This is how you can create a new layer with this class:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;L.cartoDB('http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT * FROM nz_tour')&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This will create a layer with the default Leaflet markers:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-pRmFrpJNMeE/UHIkw1E4Q2I/AAAAAAAAKXY/emA_D65dRIE/s1600/cartodb2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="580" src="http://2.bp.blogspot.com/-pRmFrpJNMeE/UHIkw1E4Q2I/AAAAAAAAKXY/emA_D65dRIE/s640/cartodb2.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
If you want custom markers and popups, all the functionality available for the GeoJSON layer can also be used for the CartoDB layer:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3850199.js?file=map.js"&gt;&lt;/script&gt;

The interactive map looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://earthatlas.info/nz/?lat=-39&amp;amp;lng=176&amp;amp;zoom=7&amp;amp;layers=Tour" width="100%"&gt;&lt;/iframe&gt;

&lt;a href="http://earthatlas.info/nz/?lat=-39&amp;amp;lng=176&amp;amp;zoom=7&amp;amp;layers=Tour"&gt;Fullscreen map&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
You can add a marker to the map by adding a new row to your CartoDB table. Dead simple!&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/oMKroqKQMtk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/2099362100706567666/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=2099362100706567666" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/2099362100706567666?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/2099362100706567666?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/oMKroqKQMtk/mapping-new-zealand-using-leaflet-with.html" title="Creating a &quot;Where I've Been&quot; map with Leaflet and CartoDB" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-P3Gi5K85mtI/UHIktQ9oj1I/AAAAAAAAKXQ/_kqPJe7JZSA/s72-c/cartodb.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/10/mapping-new-zealand-using-leaflet-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0EBSH4-fyp7ImA9WhNREE4.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-3706796840586221199</id><published>2012-09-30T12:45:00.001+01:00</published><updated>2012-11-04T14:34:19.057Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T14:34:19.057Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="TileMill" /><category scheme="http://www.blogger.com/atom/ns#" term="MBTiles" /><title>Mapping New Zealand: Exporting tiles from TileMill</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I wanted to publish a tiled version of my New Zealand maps. I first tried to upload my maps directly to MapBox.com from TileMill, but their free plan (50 MB upload storage) was not enough for all my zoom levels. This blog post describes an alternative, and a bit more complicated, way to publish your maps from TileMill.&lt;br /&gt;
&lt;br /&gt;
TileMill uses a clever format called &lt;a href="http://mapbox.com/developers/mbtiles/"&gt;MBTiles&lt;/a&gt;. This is an open specification from MapBox capabale of storing millions of tiles in a single &lt;a href="http://www.sqlite.org/"&gt;SQLite&lt;/a&gt; database. You can download your maps as MBTiles from the TileMill interface. This was easy to do for &lt;a href="http://blog.thematicmapping.org/2012/09/mapping-new-zealand-doing-magic-with.html"&gt;my topographic map&lt;/a&gt;, and a bit more tricky for &lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-using-shaded.html"&gt;my seafloor map&lt;/a&gt; which &lt;a href="http://blog.thematicmapping.org/2012/09/mapping-new-zealand-dealing-with.html"&gt;crosses the antimeridian&lt;/a&gt;. TileMill don't allow you to select an area for export which crosses the antimeridian, without making a full roundrip around the Earth:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-3mf-5fF7laA/UGgm1Q7jpsI/AAAAAAAAKWY/AuaTbdH7YVI/s1600/tilemill-export.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-3mf-5fF7laA/UGgm1Q7jpsI/AAAAAAAAKWY/AuaTbdH7YVI/s1600/tilemill-export.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Almost 45,000 tiles are needed to cover this big area for zoom level 0 to 9, while only 4700 tiles are needed to cover the area with data. Although TileMill has &lt;a href="http://mapbox.com/developers/mbtiles/#using_views_to_reference_redundant_images"&gt;support for reduntant tiles&lt;/a&gt;, it's not the result I want. So I downloaded the map as two different MBTiles, one for each side of the antimeridian.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://github.com/mapbox/tilestream"&gt;There are ways&lt;/a&gt; you can serve tiles directly to the web from your MBTiles, but I haven't had time to check how to do this with my shared hosting provider, &lt;a href="http://www.bluehost.com/"&gt;Bluehost&lt;/a&gt;. Instead, I decided to extract all the images from the MBTiles and serve them directly from image folders. You can use &lt;a href="https://github.com/mapbox/mbutil"&gt;MBUtil&lt;/a&gt;, also from MapBox, to achieve this:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;mb-util nz-seafloor-1.mbtiles tiles/nz-seafloor-1&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;mb-util nz-seafloor-2.mbtiles tiles/nz-seafloor-2&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The tiles are &lt;a href="http://earthatlas.info/nz/tiles/"&gt;stored in z and x subdirectories&lt;/a&gt; such that they have a filesystem path like 0/0/0.png - a format that is supported by most web mapping clients. After the tile export, I just merged the two seafloor folders into one.&lt;br /&gt;
&lt;br /&gt;
To create an interactive map is Leaflet is very easy. Just upload the tile folders to your web server, and write a few lines of JavaScript:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3806508.js?file=nz-map.js"&gt;&lt;/script&gt;

The map looks like this: &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://earthatlas.info/nz/" width="100%"&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;a href="http://earthatlas.info/nz/"&gt;Fullscreen map&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The map is centered at the &lt;a href="http://en.wikipedia.org/wiki/Nelson,_New_Zealand#Geographical_centre_of_New_Zealand"&gt;"Geographic Center of New Zealand"&lt;/a&gt;, which is here in Nelson. &lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-Qvfn-wmor20/UGgvaAP6VlI/AAAAAAAAKWw/vbmY8TZlhUw/s1600/P1040856.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-Qvfn-wmor20/UGgvaAP6VlI/AAAAAAAAKWw/vbmY8TZlhUw/s640/P1040856.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The&lt;a href="http://en.wikipedia.org/wiki/Nelson,_New_Zealand#Geographical_centre_of_New_Zealand"&gt; geographical "centre of New Zealand"&lt;/a&gt; allegedly lies on a hilltop near the city centre of Nelson.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-AZcIG9UkPPI/UGgvemVjxPI/AAAAAAAAKW4/WcY-JDbdNbE/s1600/P1040860.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://2.bp.blogspot.com/-AZcIG9UkPPI/UGgvemVjxPI/AAAAAAAAKW4/WcY-JDbdNbE/s640/P1040860.JPG" width="638" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
We're heading off for the &lt;a href="http://www.doc.govt.nz/parks-and-recreation/tracks-and-walks/nelson-tasman/golden-bay/abel-tasman-coast-track/"&gt;Abel Tasman Coast Track&lt;/a&gt; tomorrow, and there won't be any blog updates the next week :-)&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/uc1bg-c2dJo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/3706796840586221199/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=3706796840586221199" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/3706796840586221199?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/3706796840586221199?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/uc1bg-c2dJo/mapping-new-zealand-extracting-tiles.html" title="Mapping New Zealand: Exporting tiles from TileMill" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-3mf-5fF7laA/UGgm1Q7jpsI/AAAAAAAAKWY/AuaTbdH7YVI/s72-c/tilemill-export.png" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/09/mapping-new-zealand-extracting-tiles.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4MRX08eip7ImA9WhJaFUs.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-3696380989697009558</id><published>2012-09-28T16:26:00.000+01:00</published><updated>2012-10-06T23:53:04.372+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-06T23:53:04.372+01:00</app:edited><title>Mapping New Zealand: Doing magic with TileMill</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Finally, I got some time to play with &lt;a href="http://mapbox.com/tilemill/"&gt;TileMill&lt;/a&gt;. I've added some textures to my shaded relief map, and I'm quite happy with the result. Here are a few samples:&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-99_FsJikmXk/UGW8Au3pgDI/AAAAAAAAKVo/-dGD1XTYypw/s1600/map-tongariro.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="584" src="http://3.bp.blogspot.com/-99_FsJikmXk/UGW8Au3pgDI/AAAAAAAAKVo/-dGD1XTYypw/s640/map-tongariro.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Tongariro National Park&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-mq-dkKRfm8w/UGW78yOUmTI/AAAAAAAAKVg/u0FtDkC_kvQ/s1600/map-sounds.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="566" src="http://2.bp.blogspot.com/-mq-dkKRfm8w/UGW78yOUmTI/AAAAAAAAKVg/u0FtDkC_kvQ/s640/map-sounds.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Marlborough Sounds&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-4v6jQdaa3bE/UGW71GCpVqI/AAAAAAAAKVQ/kAxXPBQkSNQ/s1600/map-glacier.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="574" src="http://3.bp.blogspot.com/-4v6jQdaa3bE/UGW71GCpVqI/AAAAAAAAKVQ/kAxXPBQkSNQ/s640/map-glacier.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Westland National Park&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-Ym8j5J8VJrI/UGW75ptw0gI/AAAAAAAAKVY/s0BLnJruUng/s1600/map-milford.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="576" src="http://2.bp.blogspot.com/-Ym8j5J8VJrI/UGW75ptw0gI/AAAAAAAAKVY/s0BLnJruUng/s640/map-milford.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Milford Sound&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
All the data I've added are from&amp;nbsp;&lt;a href="http://data.linz.govt.nz/#/search/category/topographic/nz-topo-500-data/"&gt;NZ Topo 500 from LINZ Data Service&lt;/a&gt;, and&amp;nbsp;I've tried to find natural looking colors for my map stylesheet:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-YYvlKBVrLe4/UGXD9X7F0pI/AAAAAAAAKWA/IeBlewlnTTU/s1600/map-colors.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-YYvlKBVrLe4/UGXD9X7F0pI/AAAAAAAAKWA/IeBlewlnTTU/s1600/map-colors.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3800511.js?file=style.mss"&gt;&lt;/script&gt; &lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/0Sy4aZ-ULsU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/3696380989697009558/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=3696380989697009558" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/3696380989697009558?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/3696380989697009558?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/0Sy4aZ-ULsU/mapping-new-zealand-doing-magic-with.html" title="Mapping New Zealand: Doing magic with TileMill" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-99_FsJikmXk/UGW8Au3pgDI/AAAAAAAAKVo/-dGD1XTYypw/s72-c/map-tongariro.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/09/mapping-new-zealand-doing-magic-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUEDQXoyfSp7ImA9WhJbGE8.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-8251451836917179076</id><published>2012-09-28T09:54:00.001+01:00</published><updated>2012-09-28T10:14:30.495+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-28T10:14:30.495+01:00</app:edited><title>Creating a shaded relief map of New Zealand</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
After creating a &lt;a href="http://www.reliefshading.com/"&gt;shaded relief&lt;/a&gt; map of &lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-using-shaded.html"&gt;New Zealand's seafloor&lt;/a&gt;, and it's time to move onshore. I'm going to use the same slope-enhanced hillshade technique. It was a bit tricky, but I think I've found a workflow that works.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-Tt989mJcVdA/UGVWzvUUOSI/AAAAAAAAKTI/TV05YMU8e74/s1600/shadedrelief.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="220" src="http://3.bp.blogspot.com/-Tt989mJcVdA/UGVWzvUUOSI/AAAAAAAAKTI/TV05YMU8e74/s640/shadedrelief.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
While we got a &lt;a href="http://www.niwa.co.nz/our-science/oceans/bathymetry"&gt;250 meter resolution Digital Elevation Model (DEM) of New Zealand's seafloor&lt;/a&gt;, you can download a 25 meter resolution DEM for the &lt;a href="http://lris.scinfo.org.nz/#/layer/131-nzdem-north-island-25-metre/"&gt;North&lt;/a&gt; and &lt;a href="http://lris.scinfo.org.nz/#/layer/127-nzdem-south-island-25-metre/"&gt;South Island&lt;/a&gt; from &lt;a href="http://www.landcareresearch.co.nz/"&gt;Landcare Research&lt;/a&gt;. The free datasets are available from the &lt;a href="http://lris.scinfo.org.nz/#/search/category/elevation/"&gt;LRIS portal&lt;/a&gt;, where you can also read about &lt;a href="http://lris.scinfo.org.nz/#/file/213-analysis-of-dem-accuracy/"&gt;the accuracy of the data&lt;/a&gt;. I got an invitation to visit Landcare Research when I was passing through Palmerston North. They do a lot of open source stuff, and they have some exciting projects going on!&lt;br /&gt;
&lt;br /&gt;
Also, if you have a budget, you should definately consider buying the &lt;a href="http://geographx.co.nz/what-we-do/map-data/"&gt;8 meter resolution DEM&lt;/a&gt; from the best cartographers (or &lt;i&gt;mapsmiths&lt;/i&gt; which they like to call themselves) in New Zealand -&amp;nbsp;&lt;a href="http://geographx.co.nz/"&gt;Geographix&lt;/a&gt;. They also provide some &lt;a href="http://geographx.co.nz/what-we-do/map-data/downloads/"&gt;free samples&lt;/a&gt; for you to play with. You will be amazed by the level of detail in their well-crafted maps! They were kindly offering me an office space while I was visiting Wellington, and it was great to be part of such an inspiring environment - and what a view they have from their office on the edge of the Botanic Garden: &lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-yd_TiFPKzNE/UGTvlakOjZI/AAAAAAAAKSw/auCmU6UxIY8/s1600/P1040673.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-yd_TiFPKzNE/UGTvlakOjZI/AAAAAAAAKSw/auCmU6UxIY8/s640/P1040673.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Wellington seen from &lt;a href="http://geographx.co.nz/who-we-are/company/"&gt;the Geographx office and studio&lt;/a&gt;&amp;nbsp;in the old Dominion Observatory.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Let's move on with our elevation model from Landcare Research. I first tried to merge the two DEMs for the North and South Island, but I ran into memory problems at a later stage because of the high resoltion. The commands below are covering the North Island, but the same set of techniques applies to the South Island DEM. I downloaded the GeoTIFF version of the datasets.&lt;br /&gt;
&lt;br /&gt;
The datasets are in the&amp;nbsp;&lt;a href="http://www.linz.govt.nz/geodetic/datums-projections-heights/projections/new-zealand-transverse-mercator-2000"&gt;New Zealand Transverse Mercator 2000 (NZTM2000)&lt;/a&gt; projection. As this projection is not supported by the map studio I want to use, &lt;a href="http://mapbox.com/tilemill/"&gt;TileMill&lt;/a&gt;, we need to reproject it into Web Mercator using &lt;a href="http://www.gdal.org/gdalwarp.html"&gt;gdalwarp&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdalwarp -t_srs EPSG:3785 -tr&amp;nbsp;76.4370282745361&amp;nbsp;76.4370282745361&amp;nbsp;-r bilinear lris-nzdem-north-island-25-metre-GTiff/1-0001-0001.tif nz-dem-north-11.tif&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
At the same time I'm downscaling (-tr) the dataset so it has the same resolution as zoom level 11 in the widely used &lt;a href="http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/"&gt;Web Mercator tiling scheme&lt;/a&gt;. Where do I get this 76.4370282745361 number come from?&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-Dr_QNwV9PNM/UGVXngN2SMI/AAAAAAAAKTQ/N0Kon6qg3HI/s1600/webmerc.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-Dr_QNwV9PNM/UGVXngN2SMI/AAAAAAAAKTQ/N0Kon6qg3HI/s1600/webmerc.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So to cover the world at zoom level 11 you need almost 4.2 million tiles, and it becomes 4 times more for every zoom level you add to the party. Luckily we're only mapping a small part of the world, New Zealand. Web Mercator consider the world to be a square,&amp;nbsp;40,075,016.68 meters wide and tall (the length of the Equator). With a tile size of 256 pixels you get the a maximum resolution of&amp;nbsp;40,075,016.68 / 256 =&amp;nbsp;&amp;nbsp;156,543.03390625. You get the map scale by dividing the resolution by 0.00028 (pixel size). The rest is simple math. The scale is only correct at the Equator. For&amp;nbsp;41° south latitude,&amp;nbsp;running through the Cook Strait between the North and South Island, the map scale for zoom level 11 should be around 1:360,000 &lt;a href="http://lists.osgeo.org/pipermail/metacrs/2009-April/000253.html"&gt;if my calculations are right&lt;/a&gt;&amp;nbsp;(multiply by 1.325). Read more about the map projection and tiling scheme &lt;a href="http://msdn.microsoft.com/en-us/library/bb259689.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Let's create a &lt;a href="http://blog.thematicmapping.org/2012/06/creating-color-relief-and-slope-shading.html"&gt;color relief&lt;/a&gt; from the DEM. I've created a typical color scheme which progresses from greens for lower elevations up through yellows/browns, and on to grays and white at the highest elevations:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3798745.js?file=color-relief.txt"&gt;&lt;/script&gt;

&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdaldem color-relief -co compress=lzw nz-dem-north-11.tif color-relief.txt nz-dem-north-11-relief.tif&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-yRySnDnYO5Y/UGVZzZsQI4I/AAAAAAAAKTg/absDymcDFnw/s1600/nz-dem-north-11-relief.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://4.bp.blogspot.com/-yRySnDnYO5Y/UGVZzZsQI4I/AAAAAAAAKTg/absDymcDFnw/s640/nz-dem-north-11-relief.png" width="472" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Next, I want to get rid of the green ocean by only keeping the areas within the dataset I created &lt;a href="http://blog.thematicmapping.org/2012/09/mapping-new-zealand-editing-and-merging.html"&gt;in my last blog post&lt;/a&gt;&amp;nbsp;(I've splitted the shapefile in two, one for each island):&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdalwarp -co compress=lzw -dstalpha -cutline shape/nz-north-webmerc.shp nz-dem-north-11-relief.tif nz-dem-north-11-relief-cut.tif&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-6d1d7NRnE9Q/UGVZvdL9KvI/AAAAAAAAKTY/C0srj-SjsvE/s1600/nz-dem-north-11-relief-cut.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://3.bp.blogspot.com/-6d1d7NRnE9Q/UGVZvdL9KvI/AAAAAAAAKTY/C0srj-SjsvE/s640/nz-dem-north-11-relief-cut.png" width="472" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
To create a nice looking hillshade, I'm going to apply the same technique as I did for &lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-using-shaded.html"&gt;the seafloor map&lt;/a&gt;&amp;nbsp;(where you get all the details). First we create a "normal" hillshade:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdaldem hillshade -alt 60 nz-dem-north-11.tif nz-dem-north-11-hillshade.tif&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-5Jam5iK647Y/UGVd_38RGtI/AAAAAAAAKT4/UjboyoIQYIY/s1600/nz-dem-north-11-hillshade.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://3.bp.blogspot.com/-5Jam5iK647Y/UGVd_38RGtI/AAAAAAAAKT4/UjboyoIQYIY/s640/nz-dem-north-11-hillshade.png" width="472" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Then we create a slopeshade:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;
gdaldem slope -co compress=lzw nz-dem-north-11.tif nz-dem-north-11-slope.tif&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;
gdaldem color-relief -co compress=lzw nz-dem-north-11-slope.tif slope-ramp.txt nz-dem-north-11-slopeshade.tif&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-ouR64OReNjY/UGVeGgbXYJI/AAAAAAAAKUI/DrgbMWO5YhE/s1600/nz-dem-north-11-slopeshade.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://2.bp.blogspot.com/-ouR64OReNjY/UGVeGgbXYJI/AAAAAAAAKUI/DrgbMWO5YhE/s640/nz-dem-north-11-slopeshade.png" width="472" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we use Mapnik XML to combine the hill- and slopeshading:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3798747.js?file=nz-dem-north-hillslopeshade.xml"&gt;&lt;/script&gt;

&lt;span style="font-family: Courier New, Courier, monospace;"&gt;nik2img.py nz-dem-north-hillslopeshade.xml nz-dem-north-11-hillslopeshade.tif -d 10497 14188&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
(for the South Island DEM the dimension -d is: 12637 14895)&lt;br /&gt;
&lt;br /&gt;
We also to some cutting to get rid of the ocean:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;
gdalwarp -co compress=lzw -cutline shape/nz-north-webmerc.shp nz-dem-north-11-hillslopeshade.tif nz-dem-north-11-hillslopeshade-cut.tif&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-Kgh8FFXdApA/UGVeCl_I5QI/AAAAAAAAKUA/1n_EIVT8HPc/s1600/nz-dem-north-11-hillslopesh.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://1.bp.blogspot.com/-Kgh8FFXdApA/UGVeCl_I5QI/AAAAAAAAKUA/1n_EIVT8HPc/s640/nz-dem-north-11-hillslopesh.png" width="472" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We can combine the color relief and the enhanced hillshade in TileMill (I'm keeping them separate so we can apply the hillshade to different textures):&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-I6VGxfm9G5U/UGViOyYvraI/AAAAAAAAKUg/gSw0LtY4rNI/s1600/relief-tilemill.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="340" src="http://1.bp.blogspot.com/-I6VGxfm9G5U/UGViOyYvraI/AAAAAAAAKUg/gSw0LtY4rNI/s640/relief-tilemill.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We can also add New Zealand's seafloor to the map:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-5ZOu7iPkN7s/UGVlmtpY0-I/AAAAAAAAKU4/oDbdNuKTNeQ/s1600/relief-tilemill2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="340" src="http://1.bp.blogspot.com/-5ZOu7iPkN7s/UGVlmtpY0-I/AAAAAAAAKU4/oDbdNuKTNeQ/s640/relief-tilemill2.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/aOnHpzAj5-Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/8251451836917179076/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=8251451836917179076" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/8251451836917179076?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/8251451836917179076?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/aOnHpzAj5-Q/creating-shaded-relief-map-of-new.html" title="Creating a shaded relief map of New Zealand" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-Tt989mJcVdA/UGVWzvUUOSI/AAAAAAAAKTI/TV05YMU8e74/s72-c/shadedrelief.png" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/09/creating-shaded-relief-map-of-new.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0UEQno4fCp7ImA9WhJaFks.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-5182193738312071188</id><published>2012-09-26T10:00:00.000+01:00</published><updated>2012-10-08T02:53:23.434+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-08T02:53:23.434+01:00</app:edited><title>Mapping New Zealand: Editing and merging shapefiles with QGIS</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
The data you want to map is not always in the format you need. I was looking for a dataset containing polygons for all land areas (islands) in New Zealand (1:500,000 scale), but I couldn’t find it on the &lt;a href="http://data.linz.govt.nz/#/search/category/topographic/nz-topo-500-data/"&gt;LINZ Data Portal&lt;/a&gt;. So I tried to create it myself from the data I found:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Update Oct. 8th 2012:&lt;/b&gt; &lt;i&gt;LINZ has added new polygon datasets for all land 
areas in New Zealand (see comments below), so you don't have to do the 
job described in this blog post. The techniques for editing and merging 
shapefiles are still valid. &lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://data.linz.govt.nz/#/layer/204-nz-coastlines-topo-1500k/"&gt;&lt;b&gt;NZ coastlines (Topo, 1:500k)&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
This dataset (nz-coastlines-topo-1500k.shp) contains coastlines for North Island, South Island and Stewart Island, - but not for offshore islands (most notably &lt;a href="http://en.wikipedia.org/wiki/Chatham_Islands"&gt;the Chatham Islands&lt;/a&gt;) and the smaller islands around the coast. The coastlines are represented as lines, while I need the data as island polygons. This is how I converted the lines into polygons with QGIS:&lt;br /&gt;
&lt;br /&gt;
Vector -&amp;gt; Geometry Tools -&amp;gt; Lines to polygons&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-Vvtd56iIqoE/UGKNxYh1fII/AAAAAAAAKQw/lHf9I-9UD34/s1600/qgis1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-Vvtd56iIqoE/UGKNxYh1fII/AAAAAAAAKQw/lHf9I-9UD34/s1600/qgis1.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I named the new dataset "nz-main-island-polygons.shp".&lt;br /&gt;
&lt;br /&gt;
(I wasn't able to do the same with the 1:250,000 version of the coastlines dataset, as the coastlines are divided into multiple line segments that didn’t merge in the correct order. Please let me know if anyone are able to convert this dataset into polygons! At 1:50,000 scale, LINZ is providing &lt;a href="http://data.linz.govt.nz/#/layer/1153-nz-coastlines-and-islands-polygons-topo-150k/"&gt;a dataset containing polygons for all islands&lt;/a&gt;.) &lt;br /&gt;
&lt;br /&gt;
I’ve not found data for the offshore islands at 1:500,000 scale, but the&amp;nbsp;smaller islands around the coast are available:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://data.linz.govt.nz/#/layer/211-nz-island-polygons-topo-1500k/"&gt;&lt;b&gt;NZ island polygons (Topo, 1:500k)&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
This dataset (nz-island-polygons-topo-1.shp) also contains inland islands (islands in lakes), which I don’t want. I made a copy of this dataset named "nz-coast-island-polygons.shp" and removed the inland islands manually with "Select features by freehand" in QGIS.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-3FyZHhYhqsg/UGKNyhHBIwI/AAAAAAAAKQ4/vfaYf4dr50I/s1600/qgis2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="363" src="http://3.bp.blogspot.com/-3FyZHhYhqsg/UGKNyhHBIwI/AAAAAAAAKQ4/vfaYf4dr50I/s400/qgis2.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I now want to merge the two shapefiles into one. This can easily be achieved in QGIS:&lt;br /&gt;
&lt;br /&gt;
Vector -&amp;gt; Data Management Tools -&amp;gt; Merge shapefiles to one&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-8Hsr_-N7pZg/UGKNz9p3SFI/AAAAAAAAKRA/FHL9weB6a_g/s1600/qgis3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-8Hsr_-N7pZg/UGKNz9p3SFI/AAAAAAAAKRA/FHL9weB6a_g/s1600/qgis3.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We now got a polygon shapefile (nz-land-polygons.shp) containing all land areas of New Zealand, except the missing offshore islands.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-zitKGlUEUqI/UGKN0_mRjAI/AAAAAAAAKRI/6HwPK4ubDUA/s1600/qgis4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://1.bp.blogspot.com/-zitKGlUEUqI/UGKN0_mRjAI/AAAAAAAAKRI/6HwPK4ubDUA/s400/qgis4.png" width="337" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Lastly, I also need this dataset in the Web Mercator projection (for my next blog post). I’m using &lt;a href="http://www.gdal.org/ogr2ogr.html"&gt;ogr2ogr&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;ogr2ogr -s_srs EPSG:2193 -t_srs EPSG:3785 nz-land-polygons-webmerc.shp nz-land-polygons.shp&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
(Written on a rainy day at the &lt;a href="http://www.hopewell.co.nz/"&gt;Hopewell lodge&lt;/a&gt; in &lt;a href="http://en.wikipedia.org/wiki/Marlborough_Sounds"&gt;Marlborough Sounds&lt;/a&gt;. A higly recommended place to releax a few days!)&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-FXdBo6R4Dx4/UGKQWpFBXGI/AAAAAAAAKRQ/PGsC2r9cVSw/s1600/P1040751.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-FXdBo6R4Dx4/UGKQWpFBXGI/AAAAAAAAKRQ/PGsC2r9cVSw/s640/P1040751.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/cDtWB_Qc6xY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/5182193738312071188/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=5182193738312071188" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/5182193738312071188?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/5182193738312071188?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/cDtWB_Qc6xY/mapping-new-zealand-editing-and-merging.html" title="Mapping New Zealand: Editing and merging shapefiles with QGIS" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-Vvtd56iIqoE/UGKNxYh1fII/AAAAAAAAKQw/lHf9I-9UD34/s72-c/qgis1.png" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/09/mapping-new-zealand-editing-and-merging.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QMQXg5fyp7ImA9WhJbFkk.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-5647913455310090978</id><published>2012-09-26T09:36:00.001+01:00</published><updated>2012-09-26T09:49:40.627+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-26T09:49:40.627+01:00</app:edited><title>Mapping New Zealand: Dealing with the antimeridian in TileMill</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I want to play with &lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-using-shaded.html"&gt;my new seafloor map&lt;/a&gt; in &lt;a href="http://mapbox.com/tilemill/"&gt;TileMill&lt;/a&gt;, which is a great map design studio. It’s built on top of &lt;a href="http://mapnik.org/"&gt;Mapnik&lt;/a&gt;, but instead of XML you can style your maps with &lt;a href="http://mapbox.com/tilemill/docs/manual/carto/"&gt;CartoCSS&lt;/a&gt;, which is much more user friendly. The biggest limitation of TileMill is that it only supports the &lt;a href="http://www.hydrometronics.com/downloads/Web%20Mercator%20-%20Non-Conformal,%20Non-Mercator%20(notes).pdf"&gt;Web Mercator projection&lt;/a&gt; (even though the underlying rendering engine, Mapnik, handles multiple map projections very well). Hopefully, TileMill will add support for other map projections and &lt;a href="http://blog.thematicmapping.org/2012/09/creating-custom-map-tiling-scheme-for.html"&gt;custom tiling schemes&lt;/a&gt; in the future.&lt;br /&gt;
&lt;br /&gt;
Web Mercator is clearly not the ideal map projection to use for countries far north, like Norway (use &lt;a href="http://spatialreference.org/ref/epsg/32633/"&gt;UTM 33N&lt;/a&gt;), or countries not so far south, like New Zealand (use &lt;a href="http://www.linz.govt.nz/geodetic/datums-projections-heights/projections/new-zealand-transverse-mercator-2000"&gt;NZTM2000&lt;/a&gt;).&amp;nbsp;Another problem with Web Mercator, and other projections centered at the prime meridian, is that you often get troubles crossing the &lt;a href="http://en.wikipedia.org/wiki/180th_meridian"&gt;antimeridian&lt;/a&gt;&amp;nbsp;on the opposite side. This is unfortunate for New Zealand, where the animeridian is just east of the North Island, leaving the &lt;a href="http://en.wikipedia.org/wiki/Chatham_Islands"&gt;Chatham Islands&lt;/a&gt; on the other side. When I tried to reproject my seafloor map into Web Mercator, I got a dataset that made a roundtrip around the Earth. This blog post tells you how to avoid this trip by dividing the source dataset into two parts.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-jHbsWp9jQho/UGK90J8PelI/AAAAAAAAKSA/yglauXaToq8/s1600/P1040445.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-jHbsWp9jQho/UGK90J8PelI/AAAAAAAAKSA/yglauXaToq8/s640/P1040445.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Gisborne,_New_Zealand"&gt;Gisborne&lt;/a&gt;, in northeastern New Zealand, proudly claims to be the first city in the world to greet the sun each day.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;You’ll see that this seafloor map is different from &lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-using-shaded.html"&gt;the one I created earlier&lt;/a&gt;, as I’ve masked out the islands with a white color. I did this with &lt;a href="https://gist.github.com/3786758"&gt;Mapnik XML&lt;/a&gt; using this &lt;a href="http://data.linz.govt.nz/#/layer/1153-nz-coastlines-and-islands-polygons-topo-150k/"&gt;LINZ dataset&lt;/a&gt;. I want to add land data as separate layers in TileMill.&lt;br /&gt;
&lt;br /&gt;
The seafloor map of New Zealand is 12,000 x 15,200 pixels and it crosses the antimeridian (180° longitude). This is not a problem with the original map projection, as it’s centered at 100° east longitude, and not the prime meridian (0° longitude). What happens if we reproject the dataset into Web Mercator&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdalwarp -s_srs "+proj=merc +lon_0=100 +lat_ts=-41 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs" -t_srs EPSG:3785 -co compress=lzw -r bilinear nz-seafloor.tif nz-seafloor-webmerc.tif&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
(To use &lt;a href="http://spatialreference.org/ref/epsg/3994/"&gt;Mercator 41&lt;/a&gt; with gdalwarp you need to specify the full Proj4-definition.) &lt;br /&gt;
&lt;br /&gt;
The result is a very wide image spanning &amp;nbsp;the globe (and I’m not able to get the same resolution as the original image):&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-uS7VbDWcFf0/UGK8RXLea7I/AAAAAAAAKRw/PPdQFzEc610/s1600/nz-seafloor-webmerc.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="80" src="http://4.bp.blogspot.com/-uS7VbDWcFf0/UGK8RXLea7I/AAAAAAAAKRw/PPdQFzEc610/s640/nz-seafloor-webmerc.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Instead of this wide image, I decided to split the image in two at the antimeridian with &lt;a href="http://www.gdal.org/gdal_translate.html"&gt;gdal_translate&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdal_translate -srcwin 0 0 7723 15200 -co compress=lzw nz-seafloor.tif nz-seafloor-1.tif&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdal_translate -srcwin 7724 0 4276 15200 -co compress=lzw nz-seafloor.tif nz-seafloor-2.tif&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-F1DUf6Xa1vQ/UGLAVDeAH6I/AAAAAAAAKSY/5pcz9OexPg4/s1600/seafloor-split.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://1.bp.blogspot.com/-F1DUf6Xa1vQ/UGLAVDeAH6I/AAAAAAAAKSY/5pcz9OexPg4/s640/seafloor-split.png" width="514" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This will create two new map images, one on each side of the antimeridian. There is one column of pixels, which was unfortunate enough to cross the antimerdian, that is now missing.&lt;br /&gt;
&lt;br /&gt;
Next, I’m reprojecting both images into Web Mercator using &lt;a href="http://www.gdal.org/gdalwarp.html"&gt;gdalwarp&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdalwarp -s_srs "+proj=merc +lon_0=100 +lat_ts=-41 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs" -t_srs EPSG:3785 -co compress=lzw -r bilinear nz-seafloor-1.tif nz-seafloor-1-webmerc.tif&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdalwarp -s_srs "+proj=merc +lon_0=100 +lat_ts=-41 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs" -t_srs EPSG:3785 -co compress=lzw -r bilinear nz-seafloor-2.tif nz-seafloor-2-webmerc.tif&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Because of the missing pixel, the images don’t overlap entirely at the antimeridian. I’m therefore stretching the images a tiny bit (which is not recognizable at this scale) to make it seamless:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdal_translate -a_ullr 17482842.051 -7842209.647 20037508.34 -2796127.081 -co compress=lzw nz-seafloor-1-webmerc.tif nz-seafloor-1-webmerc-fix.tif&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdal_translate -a_ullr -20037508.34 -7842313.166 -18622711.547 -2796127.081 -co compress=lzw nz-seafloor-2-webmerc.tif nz-seafloor-2-webmerc-fix.tif&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
We now have to map images that we can load into TileMill, which will stitch them together again.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-K3XIEebNkCk/UGK76YCgfvI/AAAAAAAAKRo/ybRooamhx8o/s1600/seafloor-tilemill.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="340" src="http://4.bp.blogspot.com/-K3XIEebNkCk/UGK76YCgfvI/AAAAAAAAKRo/ybRooamhx8o/s640/seafloor-tilemill.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/sTtF6I3aUDo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/5647913455310090978/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=5647913455310090978" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/5647913455310090978?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/5647913455310090978?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/sTtF6I3aUDo/mapping-new-zealand-dealing-with.html" title="Mapping New Zealand: Dealing with the antimeridian in TileMill" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-jHbsWp9jQho/UGK90J8PelI/AAAAAAAAKSA/yglauXaToq8/s72-c/P1040445.JPG" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/09/mapping-new-zealand-dealing-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4ERns8cSp7ImA9WhJbGE8.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-1478635995600443089</id><published>2012-09-22T13:09:00.000+01:00</published><updated>2012-09-28T10:01:47.579+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-28T10:01:47.579+01:00</app:edited><title>Creating a custom map tiling scheme for New Zealand’s seafloor</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
First of all I want to thank Brent Wood at &lt;a href="http://www.niwa.co.nz/"&gt;National Insitute of Water &amp;amp; Atmospheric Research&lt;/a&gt; (NIWA) for inviting me to their office after writing &lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-of-new-zealand.html"&gt;my first blog post &lt;/a&gt;about seafloor mapping in New Zealand. Luckily I happened to be in Wellington where they are located, the best city in New Zealand (see photos below)! I was also fortunate to meet Kevin Mackay, the Marine Database Manager who’s responsible for the bathymetry dataset I’ve been using to create this map. You’ll be surprised about the amount of work and data needed to create a bathymetry dataset for such a large and hidden area of our planet. This mapping has been beneficial to New Zealand, as they have been able to &lt;a href="http://www.mfat.govt.nz/Media-and-publications/Features/990-NZ-extended-seabed-claim.php"&gt;claim rights to 1.7 million square kilometers of extended continental seabed&lt;/a&gt;, an area about six times New Zealand’s total land area.&lt;br /&gt;
&lt;br /&gt;
In &lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-using-shaded.html"&gt;the last blog post&lt;/a&gt; we created a seafloor map of New Zealand using shading relief. The map image we created was very large, 12000 x 15200 pixels, with a resolution of 250 meters per pixel. To create an interactive web map we need to cut the image into tiles for a number of zoom levels. &amp;nbsp;As I’m using a custom map projection (&lt;a href="http://spatialreference.org/ref/epsg/3994/"&gt;Mercator 41&lt;/a&gt;), I also have to define a custom tiling scheme. This is my suggestion:&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-_boJnKkytTA/UF2nbqROGvI/AAAAAAAAKNk/6a6yCm55mYw/s1600/nz-seafloor-tiles.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="616" src="http://4.bp.blogspot.com/-_boJnKkytTA/UF2nbqROGvI/AAAAAAAAKNk/6a6yCm55mYw/s640/nz-seafloor-tiles.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
The red area shows the extent of the dataset. The yellow squares show the tiles for zoom level 0 to 2. The biggest square covers an area of 4,096,000 x 4,096,000 meters. &amp;nbsp;Data nerds will know that this number is easily divided by 256, the de facto size of map tiles in pixels. The tile area is defined by&amp;nbsp;these bounds (left, bottom, right, top): 4200000, -6096000, 8296000, -2000000.&amp;nbsp;This table shows the resolution and scale for all zoom levels:&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-qZHSAmDyU1E/UF2oEusCrxI/AAAAAAAAKNs/OnkqlWhZzyA/s1600/tiling-scheme.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-qZHSAmDyU1E/UF2oEusCrxI/AAAAAAAAKNs/OnkqlWhZzyA/s1600/tiling-scheme.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
Zoom level 6 is maching the resolution of our dataset, 250 meters per pixel.&amp;nbsp;We now have the information we need to define the tiling scheme in TileCache:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;[nz-seafloor]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;type=Mapnik&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;src=EPSG:3994&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;bbox=4200000,-6096000,8296000,-2000000&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;maxResolution=16000&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;mapfile=/home/turban/NZ/Bathymetry/nz-seafloor.xml&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I’m not going into detail here, read more about how you can define custom tiling schemes with TileCache, Mapnik and Leaflet in &lt;a href="http://blog.thematicmapping.org/2012/07/using-custom-projections-with-tilecache.html"&gt;this blog post&lt;/a&gt;.&amp;nbsp;I’m using tilecache_seed.py to render the map tiles:&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;tilecache_seed.py -f nz-seafloor 0 7&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Next, we can use Leaflet to load the tiles into an interactive map:&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;script src="https://gist.github.com/3765973.js?file=nz-seafloor.js"&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
This is what the map looks like:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://earthatlas.info/nz/seafloor/" width="100%"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://earthatlas.info/nz/seafloor/"&gt;Show fullscreen&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
A few photos from the best captial city in the world, Wellington:&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-9GZ0yHd9Mvc/UF3CA5AMGXI/AAAAAAAAKQM/ESjnMh87kYo/s1600/P1040634.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-9GZ0yHd9Mvc/UF3CA5AMGXI/AAAAAAAAKQM/ESjnMh87kYo/s640/P1040634.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-DD464shAuLk/UF3CDhR_oSI/AAAAAAAAKQc/Y1v2rmgnSN8/s1600/P1040703.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-DD464shAuLk/UF3CDhR_oSI/AAAAAAAAKQc/Y1v2rmgnSN8/s640/P1040703.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/d2LShx5_i7I" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/1478635995600443089/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=1478635995600443089" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/1478635995600443089?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/1478635995600443089?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/d2LShx5_i7I/creating-custom-map-tiling-scheme-for.html" title="Creating a custom map tiling scheme for New Zealand’s seafloor" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-_boJnKkytTA/UF2nbqROGvI/AAAAAAAAKNk/6a6yCm55mYw/s72-c/nz-seafloor-tiles.png" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/09/creating-custom-map-tiling-scheme-for.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C08FRHg6eCp7ImA9WhJbEUk.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-5182622782359660205</id><published>2012-09-20T05:54:00.000+01:00</published><updated>2012-09-20T12:50:15.610+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-20T12:50:15.610+01:00</app:edited><title>Creating a seafloor map using shaded relief</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I'll use &lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-of-new-zealand.html"&gt;the bathymetry data from NIWA&lt;/a&gt; to create a seafloor map of New Zealand using shaded relief techniques. I used the same techniques &lt;a href="http://blog.thematicmapping.org/2012/06/digital-terrain-modeling-and-mapping.html"&gt;when I created the terrain map&lt;/a&gt; of Jotunheimen in Norway, so I won't go into detail here.&lt;br /&gt;
&lt;br /&gt;
Let’s start by creating a &lt;a href="http://blog.thematicmapping.org/2012/06/creating-color-relief-and-slope-shading.html"&gt;color relief&lt;/a&gt; of the seafloor. I’ve used a blue color gradient similar to the one &lt;a href="http://www.niwa.co.nz/node/82331"&gt;used by NIWA&lt;/a&gt;, progressing from light shallows to dark depths.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-zqqlxhKD2XQ/UFrrG_d3zPI/AAAAAAAAKMo/AHDhFOwilus/s1600/debth-ramp.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-zqqlxhKD2XQ/UFrrG_d3zPI/AAAAAAAAKMo/AHDhFOwilus/s1600/debth-ramp.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr align="left"&gt;&lt;td class="tr-caption"&gt;Source: &lt;a href="http://www.niwa.co.nz/node/82331"&gt;NIWA&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3754053.js?file=depth-gradient.txt"&gt;&lt;/script&gt;
&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;gdaldem color-relief -co compress=lzw nz-bathymetry.tif depth-gradient.txt nz-bathymetry-relief.tif&lt;/span&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-KHbJOKQSkbg/UFqSQaOuSpI/AAAAAAAAKLU/nqTE1IsRXm0/s1600/nz-bathymetry-relief-small.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://4.bp.blogspot.com/-KHbJOKQSkbg/UFqSQaOuSpI/AAAAAAAAKLU/nqTE1IsRXm0/s640/nz-bathymetry-relief-small.png" width="504" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I want to enhance the view by using a couple of hillshade techniques. Let’s create a plain hillshade with gdaldem:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdaldem hillshade -alt 60 -az 135 -co compress=lzw nz-bathymetry.tif nz-bathymetry-hillshade.tif&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the light source (-az) is not from the default top left position (azimuth = 315°), but in a bottom right position (azimuth = 135°). The reason for this is that bathymetry data are inverted compared to elevation data, with higher depths having higher values. &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-g1MZ7GunTK0/UFrtv5RBvNI/AAAAAAAAKM8/rFBY8046Vx0/s1600/hillshade.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="465" src="http://4.bp.blogspot.com/-g1MZ7GunTK0/UFrtv5RBvNI/AAAAAAAAKM8/rFBY8046Vx0/s640/hillshade.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The problem with this hillshade is that it’s all grey, and this grey color will blend with our color relief.&lt;br /&gt;
To enhance the hillshade we can apply another technique. This technique is described in the document &lt;a href="http://www.globalmapperforum.com/wp-content/uploads/downloads/2010/05/Creating-Slope-Enhanced-Shaded-Relief-Using-Global-Mapper.pdf"&gt;“Creating Slope-Enhanced Shaded-Relief Using Global Mapper”&lt;/a&gt; by Kent D. Brown at Utah Geological Survey. The technique clears out the gray from low-angle slopes so the map colors are not "muddied" by shading.&amp;nbsp;The document describes how to do this in &lt;a href="http://www.bluemarblegeo.com/global-mapper/"&gt;Global Mapper&lt;/a&gt;, but we’ll try to do the same the hard way with &lt;a href="http://www.gdal.org/"&gt;GDAL&lt;/a&gt; and &lt;a href="http://mapnik.org/"&gt;Mapnik&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
As described in &lt;a href="http://blog.thematicmapping.org/2012/06/creating-color-relief-and-slope-shading.html"&gt;my previous blog post&lt;/a&gt;, creating slope shading is a two-step process. First we need to create a raster from the bathymetry data where each pixel contains an angle, varying from 0 to 90 degrees as the seafloor ranges from horizontal to vertical:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdaldem slope -co compress=lzw nz-bathymetry.tif nz-bathymetry-slope.tif &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Secondly, we use this raster to slope shading by assigning a color to each pixel, using the same technique as for color relief. What we’ll do is to turn all slopes of 0° white, and any slope above 5° black. Anything in between will be in various shades of gray. Adding these two lines to the configuration file will do the trick:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3754064.js?file=slope-ramp.txt"&gt;&lt;/script&gt;

We can then create slope shading with this command:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdaldem color-relief -co compress=lzw nz-bathymetry-slope.tif slope-ramp.txt nz-bathymetry-slopeshade.tif&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-Jw5LSaOQzT8/UFqShXxt7RI/AAAAAAAAKLk/DddhbXuaMqE/s1600/nz-bathymetry-slopeshade-small.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://2.bp.blogspot.com/-Jw5LSaOQzT8/UFqShXxt7RI/AAAAAAAAKLk/DddhbXuaMqE/s640/nz-bathymetry-slopeshade-small.png" width="504" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Next we can &lt;a href="http://blog.thematicmapping.org/2012/07/terrain-mapping-with-mapnik.html"&gt;use Mapnik to combine the hill- and slope shade&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3754069.js?file=nz-bathymetry-hillslopeshade.xml"&gt;&lt;/script&gt;

&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;nik2img.py nz-bathymetry-hillslopeshade.xml nz-bathymetry-hillslopeshade.tif -d 12000 15200&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-L-0wDrokypo/UFsCsxwCAII/AAAAAAAAKNQ/lXTYnPjVkXk/s1600/hillslopeshade.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="458" src="http://2.bp.blogspot.com/-L-0wDrokypo/UFsCsxwCAII/AAAAAAAAKNQ/lXTYnPjVkXk/s640/hillslopeshade.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;br /&gt;&lt;/div&gt;
Lastly, we can combine this enhanced hillshade with the color relief, together with a few datasets from &lt;a href="http://data.linz.govt.nz/"&gt;LINZ Data Service&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;script src="https://gist.github.com/3754077.js?file=nz-seafloor.xml"&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div class="separator" style="clear: both;"&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;nik2img.py nz-seafloor.xml nz-seafloor.tif -d 12000 15200 --projected-extent 4800000 -5900000 7800000 -2100000&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-estIFCxYYL8/UFqY67Z-25I/AAAAAAAAKMA/XQP_Hbm-Jl4/s1600/nz-seafloor-small.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://4.bp.blogspot.com/-estIFCxYYL8/UFqY67Z-25I/AAAAAAAAKMA/XQP_Hbm-Jl4/s640/nz-seafloor-small.png" width="504" /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/--g8Crkwjjgg/UFqoq6Wgw0I/AAAAAAAAKMU/DQ8k9nOcx4U/s1600/nz-seafloor-north.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="460" src="http://4.bp.blogspot.com/--g8Crkwjjgg/UFqoq6Wgw0I/AAAAAAAAKMU/DQ8k9nOcx4U/s640/nz-seafloor-north.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In my next blog post, I'll turn this image into an interactive web map.&amp;nbsp;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/cEhl4at4bmc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/5182622782359660205/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=5182622782359660205" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/5182622782359660205?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/5182622782359660205?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/cEhl4at4bmc/creating-seafloor-map-using-shaded.html" title="Creating a seafloor map using shaded relief" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-zqqlxhKD2XQ/UFrrG_d3zPI/AAAAAAAAKMo/AHDhFOwilus/s72-c/debth-ramp.jpg" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/09/creating-seafloor-map-using-shaded.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEMERX8ycCp7ImA9WhJbE08.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-7228763756042532339</id><published>2012-09-19T12:04:00.003+01:00</published><updated>2012-09-22T15:00:04.198+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-22T15:00:04.198+01:00</app:edited><title>Creating a Seafloor Map of New Zealand</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
New Zealand is the perfect country to map, not only because of all the free data available - it also has a very interesting topography, above &lt;i&gt;and&lt;/i&gt; below the sea surface. Actually, around 95 percent of New Zealand’s territory is under water. So I wanted to start off my mapping tour by creating a seafloor map of New Zealand.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-9msU549SqNg/UFpLzjGzogI/AAAAAAAAKLA/Rzl4rf6kLBc/s1600/P1040178.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-9msU549SqNg/UFpLzjGzogI/AAAAAAAAKLA/Rzl4rf6kLBc/s640/P1040178.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;On my way to&amp;nbsp;&lt;a href="http://en.wikipedia.org/wiki/Whakaari_/_White_Island"&gt;Whakaari / White Island&lt;/a&gt;,&amp;nbsp;New Zealand’s only active marine volcano. Why is it there and what's hiding below the surface?&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
You can get &lt;a href="http://www.niwa.co.nz/our-science/oceans/bathymetry"&gt;bathymetry data&lt;/a&gt; (underwater depth) from the&lt;a href="http://www.niwa.co.nz/"&gt; National Institute of Water and Atmospheric Research (NIWA)&lt;/a&gt;. The dataset covers New Zealand's Exclusive Economic Zone and is free to use for non-commercial purposes (&lt;a href="http://www.niwa.co.nz/node/104327"&gt;terms and conditions&lt;/a&gt;). &lt;a href="http://www.niwa.co.nz/our-science/oceans/bathymetry/further-information"&gt;This page&lt;/a&gt; describes how the data was collected. I downloaded the “NZ 250m ESRI ASCII grid 530Mb” version of the dataset.&lt;br /&gt;
&lt;br /&gt;
The zip containes two files, RegionalBathymetry2008.asc and RegionalBathymetry2008.prj. The first file contains the actual data in an &lt;a href="http://www.gdal.org/frmt_various.html#AAIGrid"&gt;ASCII grid format&lt;/a&gt;. The last file contains information about the projection used, and if you open this file in a text editor it will show you this information:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Projection &amp;nbsp; &amp;nbsp;MERCATOR
&lt;/span&gt;&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Datum &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WGS84&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Spheroid &amp;nbsp; &amp;nbsp; &amp;nbsp;WGS84&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Units &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; METERS&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Zunits &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NO&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Xshift &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.0&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Yshift &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.0&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Parameters &amp;nbsp; &amp;nbsp;&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp;100 &amp;nbsp;0 &amp;nbsp;0.0 /* longitude of central meridian&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp;-41 &amp;nbsp;0 &amp;nbsp;0.0 /* latitude of true scale&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;0.0 /* false easting (meters)&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;0.0 /* false northing (meters)&lt;/span&gt;

&lt;/pre&gt;
What does it tell us?&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;The dataset is in a &lt;a href="http://en.wikipedia.org/wiki/Mercator_projection"&gt;Mercator projection&lt;/a&gt;. This is clearly not the best map projection to use for New Zealand, but the "official" projection,&amp;nbsp;&lt;a href="http://www.linz.govt.nz/geodetic/datums-projections-heights/projections/new-zealand-transverse-mercator-2000"&gt;New Zealand Transverse Mercator 2000 (NZTM2000)&lt;/a&gt;, is only applicable for the main New Zealand island group.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;It’s using the &lt;a href="http://en.wikipedia.org/wiki/World_Geodetic_System"&gt;WGS84&lt;/a&gt; spheroid.&lt;/li&gt;
&lt;li&gt;The coordinate unit is meters.&lt;/li&gt;
&lt;li&gt;The central meridian is not the &lt;a href="http://en.wikipedia.org/wiki/Prime_meridian"&gt;prime meridian&lt;/a&gt; (0° longitude), but 100° east longitude. This is useful, as we avoid problems with the &lt;a href="http://en.wikipedia.org/wiki/180th_meridian"&gt;antimeridian&lt;/a&gt; (180° longitude), which is passing through the area. I’ll explain these problems in a later blog post.&lt;/li&gt;
&lt;li&gt;The scale of a map using this projection will only be true at 41° south latitude, running through the Cook Strait between the North and South Islands.&lt;/li&gt;
&lt;/ul&gt;
The code for this projection in &lt;a href="http://spatialreference.org/ref/epsg/3994/"&gt;ESPG:3994&lt;/a&gt;&amp;nbsp;and the Proj4 definition (we'll use this one later) is "+proj=merc +lon_0=100 +lat_ts=-41 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs".&lt;br /&gt;
&lt;br /&gt;
You can use the &lt;a href="http://www.gdal.org/gdalinfo.html"&gt;gdalinfo&lt;/a&gt;&amp;nbsp;command to obtain more information about the dataset:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdalinfo -mm RegionalBathymetry2008.asc&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Driver: AAIGrid/Arc/Info ASCII Grid&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Files: RegionalBathymetry2008.asc&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RegionalBathymetry2008.prj&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Size is 12115, 15391&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Coordinate System is:&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;PROJCS["unnamed",&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; GEOGCS["WGS 84",&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DATUM["WGS_1984",&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPHEROID["WGS 84",6378137,298.257223563,&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AUTHORITY["EPSG","7030"]],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TOWGS84[0,0,0,0,0,0,0],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AUTHORITY["EPSG","6326"]],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PRIMEM["Greenwich",0,&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AUTHORITY["EPSG","8901"]],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UNIT["degree",0.0174532925199433,&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AUTHORITY["EPSG","9108"]],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AUTHORITY["EPSG","4326"]],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; PROJECTION["Mercator_1SP"],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; PARAMETER["latitude_of_origin",100],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; PARAMETER["central_meridian",0],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; PARAMETER["scale_factor",1],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; PARAMETER["false_easting",-41],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; PARAMETER["false_northing",0],&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; UNIT["METERS",1]]&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Origin = (4795705.551502100200000,-2067845.457881099500000)&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Pixel Size = (250.000000000000000,-250.000000000000000)&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Corner Coordinates:&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Upper Left &amp;nbsp;( 4795705.552,-2067845.458)&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Lower Left &amp;nbsp;( 4795705.552,-5915595.458)&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Upper Right ( 7824455.552,-2067845.458)&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Lower Right ( 7824455.552,-5915595.458)&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Center &amp;nbsp; &amp;nbsp; &amp;nbsp;( 6310080.552,-3991720.458)&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;Band 1 Block=12115x1 Type=Float32, ColorInterp=Undefined&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; Computed Min/Max=-3367.677,10069.260&lt;/span&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; NoData Value=-9999&lt;/span&gt;

&lt;/pre&gt;
In addition to the projection facts, what does it tell us?&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;The image or grid size is 12,115 x 15,391 pixels or cells.&lt;/li&gt;
&lt;li&gt;Each pixel or grid cell covers an area of 250 x 250 meters.&lt;/li&gt;
&lt;li&gt;The extent of the area is defined by four coordinate pairs. The size of the area is 3,028,750 x 3,847,750 meters.&lt;/li&gt;
&lt;li&gt;The image is single band and the debth data is stored as 32-bit floating-point numbers. The maximum depth is 10,669 meters. Interestingly, the minimum depth is -3,368 meters. This tells us that the dataset also contains onshore elevation data, and the lowest number is actually 3.368 meters above sea level. I’m not sure why this is almost 400 meters below the Mount Cook, the highest mountain in New Zealand (3,754 m).&lt;/li&gt;
&lt;/ul&gt;
Let’s add the information we’ve got on Google Earth:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-zZc15sOXE10/UFml3q3h7cI/AAAAAAAAKKU/Iev4UisRGRE/s1600/nz-bathymetry-extetnt.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="486" src="http://1.bp.blogspot.com/-zZc15sOXE10/UFml3q3h7cI/AAAAAAAAKKU/Iev4UisRGRE/s640/nz-bathymetry-extetnt.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The red area shows the extent of the dataset. The yellow lines show the equator and the central meridian (100° east longitude). The pin is located at the origin of the coordinate reference system (0, 0). The black line is at 41° south latitude, where we have true scale (250 meters per pixel). &amp;nbsp;The resolution will be higher further south, and lower as we move north.&lt;br /&gt;
&lt;br /&gt;
To make the calculations easier to follow, I’m going to crop the dataset a bit with &lt;a href="http://www.gdal.org/gdal_translate.html"&gt;gdal_translate&lt;/a&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;gdal_translate -projwin 4800000 -2100000 7800000 -5900000 -a_ullr 4800000 -2100000 7800000 -5900000 -co compress=lzw RegionalBathymetry2008.asc nz-bathymetry.tif&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This command will create a dataset that has a size of 12,000 x 15,000 pixels within an area of 3,000,000 x 3,800,000 meters (3,000 x 3,800 km). The resolution is still 250 meters per pixel.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;div class="MsoNormal"&gt;
&lt;span lang="EN-US"&gt;In the &lt;a href="http://blog.thematicmapping.org/2012/09/creating-seafloor-map-using-shaded.html"&gt;nextblog post&lt;/a&gt; we’ll start playing with the data.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span lang="EN-US"&gt;----&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span lang="EN-US"&gt;A few more photos from White Island:&lt;/span&gt;&lt;br /&gt;
&lt;span lang="EN-US"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-FPuvNDA0y_s/UF27w0Bo-VI/AAAAAAAAKP4/X2uRvl0QCmQ/s1600/P1040335.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-FPuvNDA0y_s/UF27w0Bo-VI/AAAAAAAAKP4/X2uRvl0QCmQ/s640/P1040335.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-M9tB6eY3jDo/UF27pnKaRVI/AAAAAAAAKPI/CoKCVvot0qk/s1600/P1040212.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-M9tB6eY3jDo/UF27pnKaRVI/AAAAAAAAKPI/CoKCVvot0qk/s640/P1040212.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span class="fbPhotosPhotoCaption" id="fbPhotoSnowliftCaption" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; outline: none; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; width: auto; word-spacing: 0px;" tabindex="0"&gt;&lt;span class="hasCaption"&gt;Towards the crater.&lt;/span&gt;&lt;/span&gt;&lt;span class="fbPhotoTagList" id="fbPhotoSnowliftTagList" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="fcg" style="color: grey;"&gt;&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-pA7LOtBh3kM/UF27q9cW6KI/AAAAAAAAKPQ/G9TjGQhKD2o/s1600/P1040243.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-pA7LOtBh3kM/UF27q9cW6KI/AAAAAAAAKPQ/G9TjGQhKD2o/s640/P1040243.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-mwWHsb8BjCQ/UF27sDzsZ1I/AAAAAAAAKPY/ERuAsykjEuU/s1600/P1040266.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-mwWHsb8BjCQ/UF27sDzsZ1I/AAAAAAAAKPY/ERuAsykjEuU/s640/P1040266.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span class="fbPhotosPhotoCaption" id="fbPhotoSnowliftCaption" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; outline: none; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; width: auto; word-spacing: 0px;" tabindex="0"&gt;&lt;span class="hasCaption"&gt;Between July and August 2012 White Island showed signs of increased activity with lake and gas levels rising from inside the crater. On 5 August 2012 a minor eruption occurred, rising the alert level to 2 of 5.&lt;/span&gt;&lt;/span&gt;&lt;span class="fbPhotoTagList" id="fbPhotoSnowliftTagList" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="fcg" style="color: grey;"&gt;&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-mlHdn-jL0Ug/UF27te6dTVI/AAAAAAAAKPg/QpV07rjAixI/s1600/P1040269.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-mlHdn-jL0Ug/UF27te6dTVI/AAAAAAAAKPg/QpV07rjAixI/s640/P1040269.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline !important; float: none; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;The main crater. &lt;/span&gt;&lt;span class="fbPhotosPhotoCaption" id="fbPhotoSnowliftCaption" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; outline: none; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; width: auto; word-spacing: 0px;" tabindex="0"&gt;&lt;span class="hasCaption"&gt;Where's gollum?!?&lt;/span&gt;&lt;/span&gt;&lt;span class="fbPhotoTagList" id="fbPhotoSnowliftTagList" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="fcg" style="color: grey;"&gt;&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-jwP8rDDH32w/UF27ue2bLyI/AAAAAAAAKPo/O5l7KCk4CUk/s1600/P1040292.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-jwP8rDDH32w/UF27ue2bLyI/AAAAAAAAKPo/O5l7KCk4CUk/s640/P1040292.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline !important; float: none; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;Walking on the moon. Virtually no vegetation survives the harsh acidic environment.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-kyl58dx8zi4/UF27vnXTcGI/AAAAAAAAKPw/zy0yDuhHAl0/s1600/P1040322.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-kyl58dx8zi4/UF27vnXTcGI/AAAAAAAAKPw/zy0yDuhHAl0/s640/P1040322.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span class="fbPhotosPhotoCaption" id="fbPhotoSnowliftCaption" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; outline: none; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; width: auto; word-spacing: 0px;" tabindex="0"&gt;&lt;span class="hasCaption"&gt;Numerous failed attempts were made to mine sulphur from White Island. Before the days of antibiotics, sulphur was used in medicines as an antibacterial agent, in the making of match heads, and for sterilising wine corks.&lt;/span&gt;&lt;/span&gt;&lt;span class="fbPhotoTagList" id="fbPhotoSnowliftTagList" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="fcg" style="color: grey;"&gt;&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/BHwmfJ2P2vU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/7228763756042532339/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=7228763756042532339" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/7228763756042532339?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/7228763756042532339?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/BHwmfJ2P2vU/creating-seafloor-map-of-new-zealand.html" title="Creating a Seafloor Map of New Zealand" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-9msU549SqNg/UFpLzjGzogI/AAAAAAAAKLA/Rzl4rf6kLBc/s72-c/P1040178.JPG" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/09/creating-seafloor-map-of-new-zealand.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QNRXs-fCp7ImA9WhJbE0w.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-8721354108798100838</id><published>2012-09-11T04:12:00.000+01:00</published><updated>2012-09-22T14:09:54.554+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-22T14:09:54.554+01:00</app:edited><title>Getting free data in New Zealand </title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
So far on my travels through New Zealand I’ve been a bit frustrated with the the slow and costly WiFi services. Access to publicly funded data about the country is a totally different story. It’s fast, easy, and free! Countries who lock up their publicly funded data (including my own country, Norway) should definitely look to New Zealand.&lt;br /&gt;
&lt;br /&gt;
So where can you get free data about New Zealand? As I’ve just been in the country for two weeks, I’m not the best person to answer this question. But I’ve done some research and the natives where happy to tell me &lt;a href="http://blog.thematicmapping.org/2012/08/mapping-through-new-zealand.html"&gt;when I asked this question on my blog&lt;/a&gt; a few weeks ago.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://koordinates.com/layers/global/oceania/new-zealand/"&gt;&lt;b&gt;Koordinates&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
This great Auckland-based company has created a portal which allows you to search, sort, bookmark and share geographic data sets. Download in the the format, projection and area you need, connect with web services using industry standard services or developer friendly APIs, or explore data within the browser. It’s a success story in how geodata should be distributed.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://data.linz.govt.nz/"&gt;&lt;b&gt;LINZ Data Service&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
Land Information New Zealand (LINZ) is the national provider and administrator of a wide range of geographical information. Here you can download hydrographic and topographic data (up to 1:50,000 scale), in the same easy to use Koordinates-fueled interface.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lris.scinfo.org.nz/"&gt;&lt;b&gt;LRIS Portal&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
The Land Resource Information Systems (LRIS) Portal is hosted by Landcare Research, an Environmental research organisation specialising in sustainable management of land resources. Here you can find a 25 meter Digital Elevation Model (DEM) of the North and South Island, - and a lot of data about the environment in New Zealand. Some of the data from Lancare Research is also &lt;a href="http://wiki.zen.landcareresearch.co.nz/informatics/2011/06/informatics-team-launch-geospatial-web-services/"&gt;available as a web service &lt;/a&gt;(WMS, WMS-C).&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.nlrc.org.nz/resources/datasets/"&gt;&lt;b&gt;The National Land Resource Centre (NLRC)&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
A science center coordinated by Landcare Research in collaboration with other science organisations, government and businesses. They’ve created an extensive list of datasets provided by different organisations related to land resources. &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://geodata.govt.nz/"&gt;&lt;b&gt;geodata.govt.nz&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
A catalogue of publicly-funded geospatial data, and part of New Zealand's developing national spatial data infrastructure (NSDI).&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://data.govt.nz/"&gt;&lt;b&gt;data.govt.nz&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
A directory of publicly-available, non-personal New Zealand government held datasets. This site does not host data, instead it links to datasets held on other government websites.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://digitalnz.org/"&gt;&lt;b&gt;DigitalNZ&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
An inititative led by the National Library of New Zealand helping people to use digital material from libraries, museums, government departments, publicly funded organisations, the private sector, and community groups.&lt;br /&gt;
&lt;br /&gt;
Other resources:&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;a href="http://www.niwa.co.nz/our-science/oceans/bathymetry"&gt;New Zealand Bathymetry (NIWA)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://maps.gns.cri.nz/"&gt;GNS Science&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://info.geonet.org.nz/category/ad"&gt;GeoNet&lt;/a&gt; - real time updates of earthquakes in NZ&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Have I missed something? Please add a comment below and I’ll try to keep this post updated.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
A few photos from my travels: &lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-f_GNS0AIsc8/UF2z_4Z5GUI/AAAAAAAAKOA/fXdbX3vF2as/s1600/P1030883-001.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-f_GNS0AIsc8/UF2z_4Z5GUI/AAAAAAAAKOA/fXdbX3vF2as/s640/P1030883-001.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;At the Tongariro Alpine Crossing together with a group from the great &lt;a href="http://web.env.auckland.ac.nz/public/mcw2012/"&gt;Mountain Cartography Workshop&lt;/a&gt;. &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-c5bgM7Hn6Kc/UF20BUBHjzI/AAAAAAAAKOI/TBSgBanNOxY/s1600/P1030907.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-c5bgM7Hn6Kc/UF20BUBHjzI/AAAAAAAAKOI/TBSgBanNOxY/s640/P1030907.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The Tongario Alpine Crossing, rated as the best on-day trek available in New Zealand. Part of the track is still closed after &lt;a href="http://en.wikipedia.org/wiki/Mount_Tongariro#2012_Te_M.C4.81ri_eruption"&gt;the recent eruption at Mount Tongariro&lt;/a&gt;.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-AAMor3xFaoY/UF20CRqq_aI/AAAAAAAAKOQ/4taW_c7zsjU/s1600/P1030927.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-AAMor3xFaoY/UF20CRqq_aI/AAAAAAAAKOQ/4taW_c7zsjU/s640/P1030927.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Mount_Ngauruhoe"&gt;Mount Ngauruhoe&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/Mount_Doom"&gt;Mount Doom&lt;/a&gt; in Lord of the Rings:&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-ZAEPXDQ7hiM/UF23V9niLfI/AAAAAAAAKOk/XS56Rdm-fKI/s1600/P1030991.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-ZAEPXDQ7hiM/UF23V9niLfI/AAAAAAAAKOk/XS56Rdm-fKI/s640/P1030991.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline !important; float: none; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;Geothermal activity at &lt;a href="http://en.wikipedia.org/wiki/Whakarewarewa"&gt;Whakarewarewa&lt;/a&gt;.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-Hprm7Z3MuVs/UF23W0X9TRI/AAAAAAAAKOs/n5QwMncEpDs/s1600/P1040004.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-Hprm7Z3MuVs/UF23W0X9TRI/AAAAAAAAKOs/n5QwMncEpDs/s640/P1040004.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span class="fbPhotosPhotoCaption" id="fbPhotoSnowliftCaption" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; outline: none; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; width: auto; word-spacing: 0px;" tabindex="0"&gt;&lt;span class="hasCaption"&gt;Boiling mud pool created by acid gases and steam that cause the decomposition of minerals to form a clay. The temperature is about 90-95&lt;/span&gt;&lt;/span&gt;&lt;span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #222222; display: inline !important; float: none; font-family: arial, sans-serif; font-size: x-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;°C&lt;/span&gt;&lt;span class="fbPhotosPhotoCaption" id="fbPhotoSnowliftCaption" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; outline: none; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; width: auto; word-spacing: 0px;" tabindex="0"&gt;&lt;span class="hasCaption"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="fbPhotoTagList" id="fbPhotoSnowliftTagList" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="fcg" style="color: grey;"&gt;&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-tycbvzUZ3Rk/UF23YaVYeDI/AAAAAAAAKO0/4U5encDKrIU/s1600/P1040032.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://2.bp.blogspot.com/-tycbvzUZ3Rk/UF23YaVYeDI/AAAAAAAAKO0/4U5encDKrIU/s640/P1040032.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: inline !important; float: none; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;Pohutu geyser erups once ore twice per hour and can reach heights of up to 30 meters.&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;(Written at&amp;nbsp;&lt;a href="http://www.thebeancafe.co.nz/"&gt;The Bean Café and Roastery&lt;/a&gt; in Whakatane, who has the best WiFi offer in New Zealand!)&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/nEXbQh2KFNs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/8721354108798100838/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=8721354108798100838" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/8721354108798100838?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/8721354108798100838?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/nEXbQh2KFNs/getting-free-data-in-new-zealand.html" title="Getting free data in New Zealand " /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-f_GNS0AIsc8/UF2z_4Z5GUI/AAAAAAAAKOA/fXdbX3vF2as/s72-c/P1030883-001.JPG" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/09/getting-free-data-in-new-zealand.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMASH85eip7ImA9WhJXGE0.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-5118883399226062119</id><published>2012-08-11T23:25:00.000+01:00</published><updated>2012-08-12T20:40:49.122+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-12T20:40:49.122+01:00</app:edited><title>Mapping through New Zealand</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
This autumn I’ll switch hemisphere to experience the spring in New Zealand. I’ll spend two months down under to learn more about cartography and mapping, and to go tramping. Where should I go and what should I see? I need your advice!&lt;br /&gt;
&lt;br /&gt;
My journey starts in Auckland and the &lt;a href="http://web.env.auckland.ac.nz/public/geocart2012/"&gt;GeoCart'2012&lt;/a&gt; conference, before I’m heading up to Tongariro National Park and the &lt;a href="http://web.env.auckland.ac.nz/public/mcw2012/"&gt;8th Mountain Cartography Workshop&lt;/a&gt;. Hopefully, Mount Tongario &lt;a href="http://www.nzherald.co.nz/nz/news/image.cfm?c_id=1&amp;amp;gal_objectid=10825269&amp;amp;gallery_id=127293"&gt;will stay awake&lt;/a&gt;. I’ve never been this close to an active volcano before! Then I’m free to go wherever I want. I roughly plan to stay one month on each island.&lt;br /&gt;
&lt;br /&gt;
What I would like to know:&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Are there other mapping events going on in New Zealand in September and October? Anything from conferences, small meetups to short-time courses.&lt;/li&gt;
&lt;li&gt;Are there museums or institutions worth visiting &amp;nbsp;for a map geek? I’ve seen that &lt;a href="http://www.tepapa.govt.nz/"&gt;Te Papa&lt;/a&gt; in Wellington has an impressive light up satellite photo of New Zealand.&lt;/li&gt;
&lt;li&gt;Where can I find geospatial datasets in the public domain? I would like to make my own map of New Zealand while travelling. I know about &lt;a href="http://www.linz.govt.nz/about-linz/linz-data-service/"&gt;LINZ&lt;/a&gt; and &lt;a href="http://www.nlrc.org.nz/resources/datasets"&gt;NLRC&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Do you know of an empty office desk or a remote &lt;a href="http://en.wikipedia.org/wiki/Bach_(New_Zealand)"&gt;bach&lt;/a&gt; (with WIFI!) that I could lend for a week or two. I need to do some work on my Thematic Mapping API.&lt;/li&gt;
&lt;li&gt;What will be the best tramps to do on the North Island in September and the South Island in October? I’m a dedicated cross-country skier, but I won’t bring my skis all the way from Norway - so keep it mainly below the snow line.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Other interesting sites and activities.&lt;/li&gt;
&lt;/ol&gt;
Please send me a message by adding a comment below, on &lt;a href="https://twitter.com/thematicmapping"&gt;Twitter&lt;/a&gt;, or by sending me an email: bjorn[AT]thematicmapping.org&lt;br /&gt;
&lt;br /&gt;
And, of course - here is a "Where should I go-map"!&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="600" src="http://thematicmapping.org/playground/nz/travel/" width="100%"&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
Bjørn &amp;nbsp; &lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/5nRZiu2vq-M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/5118883399226062119/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=5118883399226062119" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/5118883399226062119?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/5118883399226062119?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/5nRZiu2vq-M/mapping-through-new-zealand.html" title="Mapping through New Zealand" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><thr:total>7</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/08/mapping-through-new-zealand.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8GRXk-eip7ImA9WhJXFkQ.&quot;"><id>tag:blogger.com,1999:blog-4741970181714760187.post-2711551815080228764</id><published>2012-08-08T21:50:00.000+01:00</published><updated>2012-08-11T16:10:24.752+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-11T16:10:24.752+01:00</app:edited><title>Showing GPS tracks with Leaflet</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Last week I had a great 5 day trek through &lt;a href="http://en.wikipedia.org/wiki/Jotunheimen"&gt;Jotunheimen&lt;/a&gt; in Norway, the same area featured on this blog in a number of posts&amp;nbsp;
&lt;span style="font-family: inherit;"&gt;&lt;span style="background-color: white; line-height: 18.383333206176758px; margin: 0px; padding: 0px;"&gt;(&lt;/span&gt;&lt;a href="http://blog.thematicmapping.org/2012/06/digital-terrain-modeling-and-mapping.html" style="background-color: white; color: #2a5a8a; line-height: 18.383333206176758px; margin: 0px; padding: 0px; text-decoration: none;"&gt;1&lt;/a&gt;&lt;span style="background-color: white; line-height: 18.383333206176758px; margin: 0px; padding: 0px;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;a href="http://blog.thematicmapping.org/2012/06/creating-hillshades-with-gdaldem.html" style="background-color: white; color: #2a5a8a; line-height: 18.383333206176758px; margin: 0px; padding: 0px; text-decoration: none;"&gt;2&lt;/a&gt;&lt;span style="background-color: white; line-height: 18.383333206176758px; margin: 0px; padding: 0px;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;a href="http://blog.thematicmapping.org/2012/06/creating-color-relief-and-slope-shading.html" style="background-color: white; color: #2a5a8a; line-height: 18.383333206176758px; margin: 0px; padding: 0px; text-decoration: none;"&gt;3&lt;/a&gt;&lt;span style="background-color: white; line-height: 18.383333206176758px; margin: 0px; padding: 0px;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;a href="http://blog.thematicmapping.org/2012/07/terrain-mapping-with-mapnik.html" style="background-color: white; color: #2a5a8a; line-height: 18.383333206176758px; margin: 0px; padding: 0px; text-decoration: none;"&gt;4&lt;/a&gt;&lt;span style="background-color: white; line-height: 18.383333206176758px; margin: 0px; padding: 0px;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;a href="http://blog.thematicmapping.org/2012/07/land-cover-mapping-with-mapnik.html" style="background-color: white; color: #2a5a8a; line-height: 18.383333206176758px; margin: 0px; padding: 0px; text-decoration: none;"&gt;5&lt;/a&gt;, &lt;a href="http://blog.thematicmapping.org/2012/07/using-custom-projections-with-tilecache.html"&gt;6&lt;/a&gt;, &lt;a href="http://draft.blogger.com/"&gt;&lt;span id="goog_1337663982"&gt;&lt;/span&gt;7&lt;span id="goog_1337663983"&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="background-color: white; line-height: 18.383333206176758px; margin: 0px; padding: 0px;"&gt;)&lt;/span&gt;&lt;/span&gt;&amp;nbsp;. The trek included the Norway’s highest mountain, &lt;a href="http://en.wikipedia.org/wiki/Galdh%C3%B8piggen"&gt;Galdhøpiggen&lt;/a&gt; (2,469 m), and the deepest valley, &lt;a href="http://en.wikipedia.org/wiki/Utladalen"&gt;Utladalen&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-YyGC6XZY_jY/UCK_8WAQ8VI/AAAAAAAAKGo/MalXwh3aQqM/s1600/P1030256.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-YyGC6XZY_jY/UCK_8WAQ8VI/AAAAAAAAKGo/MalXwh3aQqM/s640/P1030256.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;A foggy day on Galdhøpiggen (2,469 m).&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-aCN0nQBlk24/UCK_9kXJ1WI/AAAAAAAAKGw/X2TKDX1Wkhk/s1600/P1030329.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="352" src="http://1.bp.blogspot.com/-aCN0nQBlk24/UCK_9kXJ1WI/AAAAAAAAKGw/X2TKDX1Wkhk/s640/P1030329.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Visdalen close to &lt;a href="http://www.spiterstulen.no/en/"&gt;Spiterstulen&lt;/a&gt; (1,100 m).&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-TpMWlRRbQAY/UCK__af1jtI/AAAAAAAAKG0/MivQMC2U5zg/s1600/P1030397.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-TpMWlRRbQAY/UCK__af1jtI/AAAAAAAAKG0/MivQMC2U5zg/s640/P1030397.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The view from &lt;a href="http://www.westcoastpeaks.com/Peaks/kyrkja.html"&gt;Kyrkja&lt;/a&gt; (2,032 m)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-b0rlzh72ZHs/UCLABCRFcqI/AAAAAAAAKHE/C6fjNgdX86s/s1600/P1030499.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://4.bp.blogspot.com/-b0rlzh72ZHs/UCLABCRFcqI/AAAAAAAAKHE/C6fjNgdX86s/s640/P1030499.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Storutla river&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-znn9vzsqQIA/UCLADEb0SoI/AAAAAAAAKHg/LiAItaBQrTg/s1600/P1030733.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://1.bp.blogspot.com/-znn9vzsqQIA/UCLADEb0SoI/AAAAAAAAKHg/LiAItaBQrTg/s640/P1030733.JPG" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Avdalen farm in Utladalen.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen="allowfullscreen" frameborder="0" height="377" src="http://www.youtube.com/embed/gDeuLHIQ01E" width="670"&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen="allowfullscreen" frameborder="0" height="377" src="http://www.youtube.com/embed/VoADQI2QgvY" width="670"&gt;&lt;/iframe&gt;




&lt;br /&gt;
&lt;br /&gt;
I used my Garmin GPSmap 60CSx to track the route, which allows me to &lt;a href="http://www.ehow.com/how_12179003_export-gpx-file-garmin-gpsmap-60csx.html"&gt;save the tracklogs&lt;/a&gt;&amp;nbsp;on the memory card. After the trek I had 5 &lt;a href="http://en.wikipedia.org/wiki/GPS_eXchange_Format"&gt;GPX&lt;/a&gt;&amp;nbsp;files, one for each day. I used &lt;a href="http://www.gpsbabel.org/"&gt;GPSBabel&lt;/a&gt; to merge the files into one GPX, &lt;a href="http://thematicmapping.org/playground/terrain/jotunheimen_track.gpx"&gt;jotunheimen_track.gpx&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Leaflet don't have native support for rendering GPX files (&lt;a href="https://github.com/shramov/leaflet-plugins"&gt;there is a plugin though&lt;/a&gt;), so I decided to convert the GPX track to &lt;a href="http://www.geojson.org/"&gt;GeoJSON&lt;/a&gt;. This can easily be done with &lt;a href="http://www.gdal.org/ogr2ogr.html"&gt;ogr2ogr&lt;/a&gt; program (part of the great &lt;a href="http://www.gdal.org/"&gt;GDAL library&lt;/a&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;ogr2ogr -f GeoJSON jotunheimen_track.json jotunheimen_track.gpx tracks&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I'm only using the tracks from the GPX files, not waypoints and routes. The command generates a file, j&lt;a href="http://thematicmapping.org/playground/terrain/jotunheimen_track.json"&gt;otunheimen_track.json&lt;/a&gt;, where the complete track is represented as GeoJSON. Leaflet has &lt;a href="http://leaflet.cloudmade.com/examples/choropleth.html"&gt;very good&lt;/a&gt; support for GeoJSON. Just assign it to a JavaScript variable and add the following lines of code (using &lt;a href="http://leaflet.cloudmade.com/2012/07/30/leaflet-0-4-released.html"&gt;Leaflet 0.4&lt;/a&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;L.geoJson(mytrack, {&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; style: {&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; color: '#ff0000',&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; weight: 1,&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; opacity: 1&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Courier New, Courier, monospace;"&gt;}).addTo(map);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
You can style the track &lt;a href="http://leaflet.cloudmade.com/reference.html#path"&gt;as you like&lt;/a&gt;. The resulting map looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;iframe frameborder="0" height="450" src="http://thematicmapping.org/playground/terrain/map/track.html" width="100%"&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://thematicmapping.org/playground/terrain/map/track.html"&gt;Fullscreen map&lt;/a&gt;


&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/thematicmapping/~4/hPVVneAjg5k" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.thematicmapping.org/feeds/2711551815080228764/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4741970181714760187&amp;postID=2711551815080228764" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/2711551815080228764?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4741970181714760187/posts/default/2711551815080228764?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/thematicmapping/~3/hPVVneAjg5k/showing-gps-tracks-with-leaflet.html" title="Showing GPS tracks with Leaflet" /><author><name>Bjørn Sandvik</name><uri>https://plus.google.com/118196887774002693676</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh5.googleusercontent.com/-Q6-h4spo6mk/AAAAAAAAAAI/AAAAAAAAKt8/d8s-z2GyKL4/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-YyGC6XZY_jY/UCK_8WAQ8VI/AAAAAAAAKGo/MalXwh3aQqM/s72-c/P1030256.JPG" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://blog.thematicmapping.org/2012/08/showing-gps-tracks-with-leaflet.html</feedburner:origLink></entry></feed>
