Magrit : a new thematic cartography tool

The article provides an overview of the features of the Magrit web application: a free online thematic mapping tool, presenting a strong pedagogical dimension and making possible to mobilize all the elements necessary for the realization of a thematic map. In this tool, several simple modes of representation are proposed such as proportional maps or choropleth maps. Other, more complex modes are also available such as smoothed maps and cartograms. Each map can be finalized thanks to layout and customization features (projection, scale, orientation, toponyms, etc.) and exported in vector format. Magrit is therefore a complete, light and versatile tool particularly adapted to cartography teaching at the university.


Introduction
GIS software and the field of data visualization have known a significant growth in recent years, especially with the emergence of phenomena such as the democratization of personal computers, their increased and miniaturized computing power, and more recently with the web 2.0 phenomena (Bakis & Valentin, 2010;Mericskay, 2011).It has also benefited from the emerging of websites such as Google maps or GeoPortail, that simplified the map creation process for ordinary users.The softwares of GIS and data visualization domains are part of the mapping, though not focused on representation.In addition, solutions focusing more clearly on the creation of maps exist but are aging and / or proprietary softwares (Cabal 1500, WinCarto, Phil-Carto, Cartes et données, etc.).With Magrit, we propose to take advantage of the new data visualization technologies in order to make available a thematic mapping tool that strictly respects methods and rules of graphic semiology through the enhancement of the processes used to represent the information.

Findings on the cartographer mapping toolbox
The software toolbox available to an individual, researcher, student or practitioner who wishes to produce maps may include various tools targeted at specific practices.However, it is possible to note several trends in mapping practices, including the mapping of thematic maps in GIS software and the ability to easily access various cartographic representations on the web.In order to differentiate geomatics and cartography learnings, thematic and statistical cartography are currently taught in several universities with PhilCarto (e.g.Paris Diderot University).It is a proprietary software (meaning that its sources are not accessible), available only as an installer for Microsoft Windows and whose development seems to have been recently stopped (there would be no more upgrades or new versions).However, this software has a rich and comprehensive documentation (which describes in particular the methods used and their meaning), an interface available in several languages, and it has been adopted in the academic field both by teachers and students.Such a software focusing particularly on the process of creating a map, leaving aside the GIS aspect (i.e.geoprocessing such as intersections or spatial selections) fits well in the cartographic software toolbox, while GIS applications do not allow easy implementation of all thematic mapping methods.Based on this observation, the need for a new tool has emerged: this tool should be maintainable, expose transparent methods, allow the use of a wide range of formats and have a strong pedagogical dimension.The tool presented here, Magrit, is therefore clearly aimed at differentiating the mapping operations of geomatics treatments in order to enable non-geomaticians or non-geographers to produce maps (e.g. policy makers, researchers in fields such as history or students undergoing training).Magrit allows to implement graphical semiology and mapping courses as well as all the elements necessary to create a map that can be mobilized (orientation, projection, title, legend, scale, free annotation, etc.) in order to obtain a finalized high-quality result.

Choosing the web and the Opensource
Developing an opensource software was an obvious choice since the beginning of the project and made sense considering tools previously developed by the members of the team.That is why the code is placed under a free license, CeCILL version 2.1, whose terms are compatible with the GPL (General Public License).This choice has not been pressured by the tools used (even though many software libraries used are placed under free licenses called "permissive", meaning that they can be included to proprietary products or commercial), but symbolizes the expression of a conviction.Indeed, the free model allows the transparency of the code and promotes the creation of a community, as it is possible to take part in the project and to report bugs brought through the Magrit repository page on the platform Github.Although this platform is mainly dedicated to developers or savvy users, it is not uncommon for projects to receive user questions, especially over an interface that lends itself voluntarily to exchanges.Choosing the web makes it possible to provide an interface accessible to a wide audience without platform restriction, and enables an easy access as well as an increased visibility.However, the application currently targets so-called "desktop" platforms rather than "mobile" devices (phones, tablets).The structure of the tool is thus that of a web application: part of the code (in this case essentially the graphical rendering) is executed in the browser of the user and another part is executed on the server (computations needed by some kind of representations), which allows the application not to be entirely dependent on the user computing power.Moreover, this choice allows the use of modern libraries in terms of data-visualization such as d3.js (Bostock, 2016) on the client side and, on the server side, libraries benefiting from a rapid development because of their popularity or solidly installed, such as GDAL and proj.4 regarding geographic transformations.Besides, the application was written to be easily translated and is already available in two languages, English and French.The user documentation is also written in French and English.In addition to the GitHub page, an online research blog has been opened.It is the channel that will be used the most to disseminate tutorials, information concerning the release of new versions and to support the project.Relying upon the network can be a constraint in places where the Internet connection is poor or non-existent and where access to a free thematic mapping tool could be useful (especially in Africa).However, there are several ways to tackle this issue.The application can be freely installed by a system administrator who would like to make it available to the stations on its network.It can also be deployed individually on a workstation in a very simple way thanks to the Docker technology; in these cases, once the installation is done the application no longer requires internet.However, these installation constraints may be prohibitive and, in order to ensure an access to the application in the most flexible way possible, its latest developments focus on the possibility of presenting the application as a stand-alone desktop software as well as through a web interface, in a strictly similar way.This process would be made possible by technical solutions such as Electron (a project supported by GitHub).By the same token, the project was the opportunity to publish, under permissive licenses, two packages on PyPI (Python Package Index, the reference repository of Python additional packages), one allowing to realize smoothed maps (smoomapy) and the second implementing the Jenks' "natural breaks" algorithm (jenkspy) and a javascript plugin (loc-i18next) to the translation framework used, i18next, was also released on NPM (Node Package Manager, the reference repository of packages for nodes.js).

An interface modeled on a map creation steps
The user interface is designed in conjunction with the main steps of map creation.This interface is intended to be unobtrusive while strongly guiding the user.The prevailing idea is to prevent novice users from making mistakes as much as possible, without overburdening the experienced users.The menu located on the left of the interface (Fig. 1) lists the different steps of creating a map in the order recommended to carry them out: • The import of the background map to be used and the possible tabular data set to be attached (Fig. 2) in a panel in which many formats (Shapefile, kml, GML, GeoJSON and TopoJSON) are accepted.It is also proposed to view the corresponding attribute data table (s) and to modify, if necessary, the join field used.
• The choice of a type of representation (Fig. 3, see descriptions in part 2.1) and related parameters (Fig. 4) represent the step of the cartographic creation which is at the heart of the application .This representation is applied to the previously inserted background map and, in the manner of a GIS software or a vector drawing software, these representations will be able to accumulate in the layer manager where their order can be modified by the user.On this panel, each icon returns to a particular mode of representation, which can be set via a dedicated dialog box.• The management of the order of the layers overlap, their different appearance parameters (transparency, line thickness, etc.) and the possibility of adding additional layers to the background map are proposed within the layer manager (Fig. 5).Inspired by both GIS software (QGis, ArcGis) and vector creation software (Inkscape, Adobe Illustrator), the application hierarchizes the information into "layers".The latter thus represent a coherent set of entities that can be represented together, in a manner analogous to a layer in a GIS software or a layer in a vector drawing software.
Fig. 5. Menu for managing layer order and parameters.
• Finally, several layout elements are provided to the user (see description in section 3.2).The map size can hence be defined (height and width in screen pixels) as well as the background color.
Various dressing elements (title, scale, legend) can be added and parameterized (Fig. 6, see description in section 2.2).The basemap can also be deeply modified by the choice and the customization of a projection (deforming, move projection center, rotating, etc.).
In addition, a standard functionality of desktop applications allows to save the work already done, both to resume and to share it later with potential collaborators.In Magrit, it is possible to export a "project" file that stores all the elements present in the current map as well as the data associated with it.This feature can be seen as a step towards the reproducibility of the mapping process.

Offered representations
Classical thematic representations are proposed, involving both "ranking", "differentiation" and "proportional" visual variables (Lambert & Zanin, 2016), in order to propose several combinations of maps (Fig. 7).Two of these representations are explained below.

Mapping ratios with choropleth maps
For the choropleth representation (Fig. 8), Magrit proposes to the user to classify his data according to several methods: quantiles, "natural breaks" (Jenks algorithm), Q6 method, geometric progression, arithmetic progression and equal-intervals.It is also possible for the user to manually enter the limits of the classification groups he wishes to use.Color palettes are applied to these groups according to different models: sequential gradation or divergent gradation (with choice of center class and choice of the presence or absence of a color specific to the central group).The currently available palettes are those of ColorBrewer, but the user may also enter the individual color codes (to be entered in rgb or hexadecimal format), and choose a color and a label for features with missing values.

Mapping stock with proportional maps
With Magrit, it is possible to choose between two types of symbols: circle and square.The surfaces of these symbols are proportional to the value of the variable studied and are either uniformly colored or via two colors marking a break in the values.If negative values are present, the display of these symbols is done by default with two colors, which find their limits at the zero value with a possibility of changes left to the user.This type of representation (Fig. 9) can be applied to both point and surface entities.In the latter case, the centroid of the entity is used.The symbols created can be moved individually so as to adjust the positioning of symbols using the centroid of a surface entity whose location is only slightly relevant to the actual shape of the entity.Besides, more original representations are proposed.Unlike the previous representations, the latter use computations that are sometimes complex to represent the data supplied by the user (Fig. 10).Two of these representations are detailed below.This method aims at freeing from the division of the entities studied by the construction of a regular grid of polygons.This regular grid serves as a reference to a density calculation (carried out on the share of the intersected value studied) and will make it possible to highlight the major trends in the spatial distribution of the data studied.In order to avoid any edge effects, only the actual surface of the cells (ie after intersection and cutting with the background map) is taken into consideration.
Several forms of cells are proposed: square, "diamonds" and hexagons (Fig. 11) and the user can choose the mesh size to use

Mapping stocks with cartograms
This type of map, sometimes called anamorphosis, consists in constructing a distorted image, the deformation of which accounts for the data represented.
In most deformation methods, the size (area) of the entities is deformed according to the variable studied.
In Magrit, several methods are given to the user.The Dorling-Demers method makes it possible to produce noncontinuous cartograms according to simple proportional symbols (circles or squares).In this method, each symbol is arranged optimally relative to the origin center of the geographical unit in question while avoiding superimpositions.The Olson method (Olson, 1976) also makes it possible to produce non-contiguous cartograms while preserving the shape of the entities studied.The area of the studied entities is hence deformed proportionally to the deviation from the mean (this first method may generate overlapping entities) or in relation to the maximum value (this method thus prevents overlaps since the entity with the highest value is the only one that will not have its surface reduced).Finally, the Dougenik method (Dougenik, 1985) (Fig. 12) enables to produce contiguous cartograms whose topology is preserved.

Map design: staging of the map
The staging of a map (Lambert & Zanin, 2016) consists of personalizing and finalizing the final result to make it aesthetic and effective.This step includes projections, map layout, and customization elements.
A wide and varied selection of projections (more than 25) is made available to the user.This selection includes classical projections adapted to cartography on a global scale (Robinson, Natural Earth, Eckert), projections related to the visualization of data on the web (projection web-Mercator), projections adapted to regional/continental mapping (Lambert Azimuthal Equal Area of Lambert Conic Conformal for example) and more original projections (Bonne's projection, Peirce's quincuncial projection), some of which have the particularity of presenting interruptions in their plots (such as the projection of Goode or the projection HEALPix, Fig. 13a).In Magrit, these projections are parameterizable: the user can interact with the background map for example by choosing the projection center or the intersecting parallels of its projection to allow customized renderings adapted to certain study areas (Fig. 13b).Thus the user can modify the projection in which the map is displayed, according to the message that the cartographic representation in the course of realization seeks to convey and according to the location of the phenomenon represented.The majority of the classic elements allowing the customization of a map are also offered to the user: text boxes (the latter have a rich formatting: font type, size, line-break, etc.), scalebar (the rounding precision is adjustable multiple units of measurements are available: meters, kilometers and miles), symbol marking the orientation of the map, personalized geometric shapes (arrows, ellipses and rectangles) allowing the emphasis of certain phenomena, graticules (allowing to symbolize in a clearer way the orientation during a small-scale work), mask representing the surface of the globe (notably allowing to visualize the cutting of the globe obtained during the use of any projection with interruptions).Finally a functionality allows the addition of labels (modifiable by layer or individually).These elements are all interactive: they can be moved with the mouse and each has a contextual menu allowing to modify its properties, to mount it or to descend it in the order of appearance on the screen as well as to suppress it.At the end of the mapping process, the application allows quality exports in png and svg formats.In order to have an easily customizable result in vector drawing software, the product svg file organizes the information in layers and the definition of the different fonts used and the possible symbols are also included, so as to ensure a faithful export of the representation displayed in the browser.

Conclusions and outlook
This tool is intended to play a significant role in the cartographic toolbox.In addition to providing a versatile tool for producing maps, the tool also aims at being a point of reference for learning thematic mapping at the university.It is in this perspective that the research book will be completed by different teaching materials (tutorials, videos, etc.).While Magrit holds a strong pedagogical dimension because of the target audiences (especially the geography students), it is also pleasant to use and not con-training for a more experienced cartographer.For this purpose, in order to facilitate its dissemination particularly at an international level, one of the priorities in its development is to make the tool accessible to a user without internet access or to allow its deployment by an administrator on a network of remote stations.Finally, beyond the perspectives of the application itself, and with a view to facilitating the design of a map by a non-geomatician user, the development of tools that are easily interoperable with Magrit is foreseen.These "satellite" tools could, for example, be used to prepare upstream data (management of a layer and its attribute data, generalization of the basemap, aggregation of entities, etc.) or to introduce the statistical cartography dimension.

Fig. 1 .
Fig. 1.Page displayed to the user when opening the application.