Skip to main content

Posts

Showing posts from October, 2012

Mapping the population density of New Zealand with QGIS, SQLite and TileMill

There are over 4.4 million people 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 Doubtful Sound in Fjordland with a permanent population of one! Where do the New Zealanders live? Let’s create a population density map of New Zealand. Doubtful Sound According to Lonely Planet , 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 only 15.5 persons per km2. Auckland I want to map the population density as a choropleth map , using darker colors for higher densities. But which units or geographical areas should I use? The regions (territorial authorities) I mapped in my last blog post are too big to show the population density of the c...

Mapping the regions of New Zealand with MapShaper and Leaflet

There are 16 regions of New Zealand , and during my trip I’ll be visiting 15 of them (I’m saving the Taranaki region 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. 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 territorial authorities (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. The geographic extents of the regions are largely based on drainage basins , following drainage divides such as the Southern Alps.  The dataset I’m using is from Statistics New Zealand , the national statistical office. Koordinates.com has made life easier by collecting geographic data from Statistics New Zealand on their portal. I’v...

Mapping New Zealand: Creating a road map

I’ve travelled around New Zealand by bus, car, boat, and by foot. In a previous blog post , 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. I've destroyed my National Geographic map while travelling around the New Zealand. How can I add the roads travelled to my digital map? Travelling around New Zealand can be quite an experience. This is a well known sight. 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 road data from LINZ for my map, but I’m sure you can achieve the same with OpenStreetMap data. First, I created an empty shapefile in QGIS 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 ...

Mapping New Zealand: Clustering DOC Huts with Leaflet

In New Zealand, long distance walking or hiking for at least one overnight stay is known as tramping . There is a great network of over 950 huts throughout New Zealand operated by the Department of Conservation (DOC). I’ve just stayed in four of the huts while tramping the Abel Tasman Coast Track , and you need a lifetime to reach them all. It’s much quicker to map them. DOC huts in the Abel Tasman National Park . Awaroa Hut 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. You can download DOC's geospatial data for free on their data portal . Unfortunately, the datasets are not available as shapefiles, so it might require some wizardry to extract the data from KML. Luckily, the Koordinates guys have done this already, and you can download the shape...

Mapping New Zealand: Where are the hot and cold springs?

New Zealand has a large number of cold and hot springs , 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.  You can find spring point dataset at LINZ Data Service , which contains 147 significant springs either by size or location. I downloaded the dataset as a shapefile, and converted it to GeoJSON using ogr2ogr : ogr2ogr -f "GeoJSON" -lco COORDINATE_PRECISION=4 nz-spring-points.json nz-spring-points-topo-150.shp  The resulting GeoJSON FeatureCollection can be assigned to a JavaScript variable: var springs = {"type":"FeatureCollection","features":[{... ... and visualised with Leaflet's GeoJSON layer and L.circleMarker : Here is the result: Fullscreen map Te WaikoropupÅ« Springs in Golden Bay, discharging 14,000 litres of water per second , - the largest freshwater springs in New...

How to control your Leaflet map with URL parameters

I needed a way to control the appearance for my Leaflet map of New Zealand , especially when embedding a map with an iframe. Leaflet have no native support for URL parameters for, like the Permalink control for OpenLayers ( there is a plugin + Leaflet-hash ). This blog post will show you how you can add support for URL parameters for map position (latitude/longitude), zoom level and active layers. First, I'm defining my layers in an JavaScript object: var layers = {   'Seafloor': L.tileLayer('tiles/nz-seafloor/{z}/{x}/{y}.png'),   'Topographic': L.tileLayer('tiles/nz-topo/{z}/{x}/{y}.png'),   'Tour': L.cartoDB('http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT * FROM new_zealand_tour') }; You can use the same object to populate the Leaflet layers control . Next, I'm extracting the URL parameters with a regular expression ( from Papermashup ): var params = {}; window.location.href.replace(/[?&]+([^=&]...

Creating a "Where I've Been" map with Leaflet and CartoDB

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 Google Fusion Tables for tasks like this. Now, I want to try CartoDB , which is Google Fusion Tables on steroids . I used the CartoDB free plan to create a simple table containg the name and location of the places I've been: You can easily query your data with the HTTP-based SQL API : http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT * FROM nz_tour This request will return all the data in the default CartoDB JSON-format. Add format=geojson , if you want the data in the GeoJSON format supported by Leaflet : http://thematicmapping.cartodb.com/api/v2/sql?q=SELECT * FROM nz_tour&format=geojson The SQL API also supports JSONP , allowing you to query your data directly from JavaScript in the web browser. Just add a callback parameter: http://thematicmapping.cartodb.com/api/v2/sq...