Time for action – converting your local or national authorities data into web mapping formats
For illustration purposes, we will use data coming from the Geographical Information System at the Commission (GISCO), a Eurostat (an European commission organism) service which promotes and stimulates the use of GIS within the European Statistical System and the Commission. We chose to use the Nomenclature of Units for Territorial
Statistics (NUTS), the main administrative units within Europe. Perform these steps to achieve the objective outlined in this paragraph:
- Go to the URL http://www.eea.europa.eu/data-and-maps/data/administrative-land-accounting-u, and click on Download file within the GIS DATA block.
- Go to http://converter.mygeodata.eu, a website to make online conversion of spatial data files, vector, and raster. On the left-hand side part, in the block Upload your data files, click on Browse to select the downloaded
ZIP file. After that, click on the Submit button. The following screenshot is the result of these two steps: - After this operation, you should see in the block My GeoData on the left-hand side part, below the previous block, a date of upload and the
shp file name NUTSV9_LEAC.shp. You will also see in the page center an Overview Map. - Scroll down to change Target vector format: to GeoJSON and Output coordinate system: to WGS84. It should be like the following image.
- Before clicking on the button Convert now!, continue to scroll down to inspect dataset information like the layer name, the input format, the geometry type (polygon, line, or point), the number of elements, the extension, the projection and its associated SRID (read again if you need to Chapter 7, Wrapping Our Heads around Projections) and the column names with their type.
- Now, click for real on the button Convert now!, wait to see a new page appear with a button Download result, and click on it. You will have to wait to see an ad before getting a
ZIP file mygeodata.json. Here's how the screen will look upon performing these steps: - Unzip the file to get a GeoJSON file named
NUTSV9_LEAC.json. Rename it now to nutsv9_lea.geojson. Our application will use it later.
We saw how we can use an external online website to have a first approach of geographical data conversion without installing specific software on your machine. You also saw that you only review a small part of the possibilities of the online tool to make conversion.
After this small conclusion, let's work more on the topic of data.
Have a go hero – find out more about GIS files
Remember that we introduced open data portals during the chapter and GIS files formats in particular in Chapter 5, Using Vector Layers. To revise and go a bit further, perform the following tasks:
- Find out your local and national open data portals, places dedicated to sharing open data and retrieve some GIS datasets
- From the first step, use the raw or converted GIS data to add it to a vector layer in your map example. It can be either GeoJSON or KML.
- Discover the documentation about shapefile, the most common GIS format. If you start to play more with cartography, you will have to know it.
- Try to discover web services such as Web Feature Service (WFS) instead of using a file; they serve content remotely. Use them instead of files, reusing your knowledge from Chapter 5, Using Vector Layers.
- Simplify the returned GeoJSON resulting from the previous conversion: it is too large. Use MapShaper for this (see the following tip to learn about this tool):
Tip
Data conversion tips
We chose to introduce you to an on-line application to make GIS data conversion. Imagine that you need to filter a large dataset and the upload size is big; you may need to use a local application for this. We advise you to do it with QGIS at http://qgis.org, an open source desktop software where you can view the geographical dataset itself in a GUI. If you prefer the command line, you'd better use GDAL (Geospatial Data Abstraction Library), a tool to make GIS data conversion, available at http://gdal.org.
You should also visit the website http://www.mapshaper.org. Contrary to the reviewed use case, the goal of MapShaper is to simplify the data in order to get a lighter dataset, in particular to gain time when loading. Do not hesitate because most of the time, you don't need a high level of precision!
Diving into the OpenLayers 3 select component
Until now, you only learned some useful skills to transform data. It was good way to reintroduce the vector layer topic. Now, let's review how you can start selecting some geographic objects on your map.