IGN wmts stream

From GRASS-Wiki
Jump to navigation Jump to search

The french IGN-API service offers a WMTS (OGC-compliant) stream for GIS-oriented data diffusion.

Connecting to this WMTS service requires a preliminary registration. See here for more information on various licence types. This AddOn was written as a transitory solution to fetch french data within GRASS 6.4 where r.in.wms module fails. Note that this module was completely rewritten for GRASS 7.0 and now works with IGN web service, except at the present time it does not properly take into account french cartographic systems (nadgrid-based datum shifting). r.in.ign does, and works with GRASS 7.0 too.

Here we expose a simple how-to, hoping it will help users importing raster layers within GRASS GIS. It is based on the use of the r.in.ign AddOn.

Warning

r.in.ign lets you query a dataset via a contract. Beware the conditions that come with it and terms of use that apply to data... It is a quite rough module, true, but all this can be easily adapted to one's personnal needs.

Dependencies

Previously should be installed on your system:

  • gdal-bin (GDALTools);
  • PROJ4 and its binary tools;
  • awk or gawk;
  • wget;
  • xmlstarlet for capabilities files analysis.

Moreover, as a reminder, your system should properly handle french cartographic projections. There should be somewhere in you PROJ system directory (usually /usr/share/proj/ on GNU/Linux OS):

  • the IGNF register, a text file called IGNF;
  • the transformation grid called ntf_r93.gsb.

Learn more here for a fine tuning of this aspect.


Setting up a server connection

First thing you need is an access to the server:

  • Create an account;
  • When logged in, from this page you can create a new contract choosing the free evaluation type ("Tester gratuitement l'API SIG"). IGN reminds you this type of contract should not be used for any professional purpose, but as a temporary development tool for your web sites or GIS applications.
  • Next, you have to provide a login/password. Be cautious with special characters here: r.in.ign may not correctly handle them (unless using escape sequence)...
  • Your contract is created after a while, then you can retrieve its apiKey in your orders recap.

Downloading the AddOn and running it

Download r.in.ign, make sure the file is executable and located in a correct path directory (e.g. /usr/local/grass-addon).

You're done!

Launch GRASS in your favorite location/mapset. Define the region of interest, caring for its extent and resolution: Whether the current resolution is coarse or fine r.in.ign will request different levels of the server's tilematrix set. First run the command with -c argument to check available layers according to the contract you subscribed:

r.in.ign -c apikey=YourPersonalApiKey user=YourLogin password=YourPassword

The -m flag in the next example allows to output 3 separate-band rasters rather than a composite RGB raster:

r.in.ign -m apikey=YourPersonalApiKey user=YourLogin password=YourPassword output=orthoign wmtslayer=ORTHOIMAGERY.ORTHOPHOTOS

How it works

r.in.ign performs the following operations:

  • detects the current location's projection system;
  • turns the region extent into pseudo-Mercator projection system coordinates (epsg:3857);
  • calculates the set of tiles to query (tilematrixset, rows & cols);
  • retrieves tiles from the server;
  • georeferences each tile;
  • merges them all into a single image;
  • then reprojects the latter in the target projection system.
  • It finally runs r.in.gdal and optionnally r.composite.