Skip to main content

Thematic mapping with GeoJSON

Is GeoJSON a suitable data interchange format for thematic world mapping? The format has a lot of potential, but there are major performance issues due to browser restrictions. I've used OpenLayers to test how choropleth maps can be rendered from GeoJSON encoded data. The map is available on this page (best performance in Firefox).

Directions Magazine has an excellent introduction to GeoJSON. Open source tools like OpenLayers, GDAL/OGR, GeoServer and FeatureServer already supports the GeoJSON draft specification.

On the map above (number of Internet users), all countries are wrapped in a FeatureCollection. Each country is represented by a Feature containing MultiPolygon geometry and parameters. By using GeoJSON you are basically transferring vector data directly to the client instead of map images. This has several advantages:
  • You can do client side processing of the data. One example is reprojecting of the data in the browser.
  • The thematic display classifications or colour range can be changed without interfering the server.
  • Possible to create a richer user interface (i.e. mouseover effects).
  • No need for advanced map server software.
  • Fast. The vector boundaries only needs to be downloaded once in a session.

The bottleneck is the vector rendering in the browser. The map above is rendered using a vector layer in OpenLayers. Depending on your browser, the polygons are rendered using SVG or VML. OpenLayers had great difficulties rendering my original world borders dataset. This dataset consists of 3775 polygons. By deleting "small" islands, I was able to reduce the number of polygons to 463. I have also greatly simplified the country borders, and reduced the number of lat/long decimals to two. The map now loads within a few seconds, even though it's a bit "shaky" in Internet Explorer. It works, but I find the boundaries oversimplified and not very useful.

MapFish contains a GeoStat widget (still in alpha-release) that shows choropleth mapping in OpenLayers. The country borders and indicator values are retrieved as GeoJSON from the server. The colouring of the polygons is done through JavaScript in the web browser. As we see, a good performance can be achieved by only mapping African countries.

Conclusion: GeoJSON has a lot of potential, but is currently not suitable for world maps due to browser restrictions.

UPDATE 6 APRIL 2008: Read follow-up post on Technical Ramblings

Data source for Internet users: UNdata

Comments

Anonymous said…
"""
Conclusion: GeoJSON has a lot of potential, but is currently not suitable for world maps due to browser restrictions.
"""

I disagree with this conclusion. GeoJSON is no worse than any other vector format. This is purely a browser limitation.
Bjørn Sandvik said…
I agree with this clarification!
Anonymous said…
Hi,
I have also done some experiments with OpenLayers vector-rendering for making Thematic maps but I'm having problems with performance when I have more than 100 polygons. I'm now working on a solution based on a WMS-service where a SLD-file is dynamicly generated on the server based on the request from the client.

Do you have any experiences on this?

The filtering technique in SLD is though rather limited. When doing the maps I first select eg 200 polygons in a layer that should be vizualized. Then on these 200 polygons I use a specific thematic rendering-scheme. When doing this in SLD I have to repeat the filter for each thematic class which I guess will degrade performance.

Michael Östling
Bjørn Sandvik said…
Hei Michael,

I've not yet had time to look at a SLD/WMS solution. I will do at a later stage of my thesis.

You might have a look at European Interactive Atlas Explorer: http://karlinapp.ethz.ch/wms_client/

The top layers shows diagrams generated using SLD (look at the source code).

The diagrams are generated server side by the open source QGIS map server: http://karlinapp.ethz.ch/qgis_wms/

Maybe this tool will improve the performance? Please let me now if you have any success.
Unknown said…
I have to disagree with you about geojson and limitations. This is basically an engineering problem. That only depends on your solution structure.

You already mentioned that you had to simplify geometries by reducing vertexes and removing some unnecessary islands. Instead of changing real data, you could do it by using databases which implemented OGC standards dynamically (eg. stsimplify). or you could write a serverside module that will reduce vertexes with using Douglas- Peucker algorithm (http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm).

Even though you use desktop technologies, showing 3775 polygon with its vertexes at the same time you will have troubles. Instead you could use scale based simplifying which is being done by most of the 3d games.

Also you can observe that maps.google.com renders 3d buildings in clientside (with using webgl). Even though webgl is a strong component, you can easily see they are also using some kind of vertex reducing algorithms dynamically (or with caching technologies scale by scale).

In conclusion, I can say that platform is defined, technologies are there but your solution was not a good one. Therefore, GeoJson is really good one but you cannot expect everyone to be capable to find good solutions which can use GeoJson.

Popular posts from this blog

Creating a WebGL Earth with three.js

This blog post will show you how to create a WebGL Earth with three.js , a great JavaScript library which helps you to go 3D in the browser. I was surprised how easy it seemed when reading a blog post  by Jerome Etienne . So I decided to give it a try using earth textures  from one of my favourite cartographers, Tom Patterson . WebGL is a JavaScript API for rendering interactive 3D graphics in modern web browsers without the use of plug-ins. Three.js is built on top of WebGL, and allows you to create complex 3D scenes with a few lines of JavaScript. If your browser supports WebGL you should see a rotating Earth below: [ Fullscreen ] To be able to display something with three.js, you need three things: a scene, a camera and a renderer. var width  = window.innerWidth,     height = window.innerHeight; var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera(45, width / height, 0.01, 1000); camera.position.z = 1.5; var rende...

Thematic Mapping Engine

It's time to introduce the Thematic Mapping Engine (TME). In my previous blog posts, I've shown various techniques of how geobrowsers can be used for thematic mapping. The goal has been to explore the possibilites and to make these techniques available to a wider audience. The Tematic Mapping Engine provides an easy-to-use web interface where you can create visually appealing maps on-the-fly. So far only prism maps are supported, but other thematic mapping techniques will be added in the upcoming weeks. The engine returns a KMZ file that you can open in Google Earth or download to your computer. My primary data source is UNdata . The above visualisation is generated by TME ( download KMZ ) and shows child mortaility in the world ( UNdata ). The Thematic Mapping Engine is also an example of what you can achieve with open source tools and datasets in the public domain: A world border dataset is loaded into a MySQL database . The same database contains tables with statistics ...

Creating 3D terrains with Cesium

Previously, I’ve used three.js to create 3D terrain maps in the browser ( 1 , 2 , 3 , 4 , 5 , 6 ). It worked great for smaller areas, but three.js doesn’t have built-in support for tiling and advanced LOD algorithms needed to render large terrains. So I decided to take Cesium for a spin. Cesium is a JavaScript library for creating 3D globes and 2D maps in the browser without a plugin. Like three.js, it uses WebGL for hardware-accelerated graphics. Cesium allows you to add your own terrain data, and this blog post will show you how. Impressed by the terrain rendering in @CesiumJS - with a 10m elevation model for Norway! Farewell Google Earth. pic.twitter.com/RQKvfu2hBb — Bjørn Sandvik (@thematicmapping) October 4, 2014 Compared to  the dying Google Earth plugin , it's quite complicated to get started with Cesium. The source code is well documented and the live coding Sandcastle is great, but there is a lack of tutorials  and my development slows down when ...