Blog

Mapping GeoJSON in CKAN

  • Dominik Moritz
  • 31 Jul 2013
A new feature in CKAN enables users to preview geographical data in GeoJSON files, a widely-used open format for geodata. The preview renders the data on an interactive map. GeoJSON is a simple file format for storing spatial features such as points and areas together with attributes. The new preview loads GeoJSON data into a Leaflet map, which shows the MapQuest base layer in the background. Points are shown as markers, and areas as polygons; click on a point or area, and a pop-up will show the details associated with it. You can also pan and zoom the map. Try it out in the demo below.
Your browser does not support iframes.
The preview is part of CKAN's spatial extension, which already offers previews for WMS resources. To enable the GeoJSON preview, ensure that the spatial extension is installed, and add geojson_preview to the ckan.plugins list in your CKAN config file. Also, if you want users to be able to view prefiles linked on remote servers, add the resource_proxy extension. Now, if you create a new resource with a GeoJSON file and set the file type to geojson (or gson), you can navigate to the resource page, where the preview will appear automatically. By default, CKAN offers previews for many file types including images, web sites, CSV files, Excel spreadsheets, JSON files and PDFs. These previews are implemented in CKAN extensions and use the IResourcePreview extension interface. This means that new previews can be added very easily, and previews are not limited to the default ones that come with CKAN. If you want to write a another kind of preview, have a look at the examples in CKAN and the interface documentation.