GSOC 2014 : Schematization Plug-in for QGIS¶
I am Nishith Maheshwari from IIIT Hyderabad, India and have been accepted for Google Summer of Code 2014 for the project Schematization Plug-in for QGIS. I am very excited and looking forward to working on the project. This wiki page will have general info and regular updates of the progress of the work.
The aim of the project is to add some functionality to create schematic maps in QGIS. This would be done by creating a plug-in which would have various map generalization/schematization functions implemented in it.
More detailed proposal is at - http://www.google-melange.com/gsoc/proposal/public/google/gsoc2014/nishithm/5741031244955648
A more detailed report of the project can be found at - https://dl.dropboxusercontent.com/u/86965637/schematization_gsoc2014.pdf
- Mentor : Luciene Delazari
- Co-mentor : Piotr Pociask
- Co-mentor : Mark Ware
Tutorials and Resources being used¶
Github Repository : https://github.com/nishithm/schematization
- How to start plug-in work and set up IDE : http://docs.qgis.org/2.2/en/docs/pyqgis_developer_cookbook/
- Documentation of functions and classes used in QGIS (C++) : http://qgis.org/api/2.2/
- Processing toolbox docs : https://docs.qgis.org/2.2/en/docs/user_manual/processing/index.html
- Introduction to scripting : http://qgissextante.blogspot.com/2013/04/geoscripting-in-sextante.html
- Tutorial for Processing framework : https://github.com/polymeris/qgis/wiki/Developer's-Tutorial
Documents, examples and datasets¶
- Sequence of activities/tasks for the plug-in : http://web.iiit.ac.in/~nishith.maheshwari/docs/Schematization%20Plugin_v1.docx
- Papers which deals with topologically consistent line simplification : http://web.iiit.ac.in/~nishith.maheshwari/docs/DP_topo.pdf , http://web.iiit.ac.in/~nishith.maheshwari/docs/topology_simplification.pdf
- Automated metro map layout method : http://web.iiit.ac.in/~nishith.maheshwari/docs/schematicmapping2014-paper1.pdf
- Starting point - example plug-in : http://web.iiit.ac.in/~nishith.maheshwari/docs/exampleprovider.zip
- OSM Dataset (unedited) : http://web.iiit.ac.in/~nishith.maheshwari/docs/SummerSchool.rar
How to Install¶
- Clone the repository or download the zip file from https://github.com/nishithm/schematization/archive/master.zip and extract it.
- Copy and paste the folder in the '.qgis2/python/plugins/' folder which would be in the home directory of the user (this is same for both Windows as well as any Linux system). Also change the name of the folder to 'schematization'.
- Now in the QGIS this plugin would show under 'Manage and Install Plugins' and would just needed to be activated there. (As this is an experimental plugin, please make sure that you have the 'Show also experimental plugins' box checked under the 'Settings').
How to use¶
- One would be 'Algorithms for simplifying layer' under which the 'Topology Preserving Simplifier' algorithm is there. This algorithm takes as input a line vector layer and returns a simplified form of the input while preserving the topology.
- The other group 'Algorithms for applying constraints' will have 'Applying Angle Constraints'. This algorithm applies the angle/direction constraint on the simplified layer (obtained from 'Topology Preserving Simplifier' algorithm). The constraint is applied in a manner such that the final output has lines oriented in either horizontal, vertical or diagonal direction. This satisfies one of the conditions for schematization and makes the map easier to read and understand.
Progress¶Before Coding Period
- Setup of coding environment Eclipse and Pydev done!
- During the bonding period it was decided after discussions with the mentors that we would create the plug-in by integrating it with the already existing functions of Processing Toolbox.
- For simplification of geometry, QgsTopologyPreservingSimplifier class will be used as the implementation is similar to Douglas Peucker algorithm and also gives us the advantage of preserving the topology. There were some errors in the output for some data sets but otherwise it is working good enough. Those errors are reduced after joining/merging the lines at intersection before simplification.
- After these things have been decided, now the first task at hand is to implement a basic plug-in which removes objects smaller than a certain threshold. This would be the initial setup for the plug-in and act as a base for it. This function for removing the smaller objects might create topology errors, so this would be available as an option in the plug-in.
- Different algorithms will be connected using models for testing purposes. Also for testing, fake QGIS instance is available at QGIS Interface
- There is exampleprovider which is available in the Processing plugin as an example plugin to add algorithms to the Processing framework. This will be used as a base.
- Have added the functionality for simplification using QgsTopologyPreservingSimplifier function in the above mentioned example plugin. But this alone is incomplete/insufficient for simplification as there is a need to do pre-processing otherwise the output won't be as desired.
- In the coming week I'll be tweaking with the models given in processing toolbox and using the algorithms already in it will implement proper pre-processing steps in the plug-in.
- Solved tickets/issues which were created by the mentor on GitHub. It included addition of progress update (in terms of percentage) while running the algorithm and also an option for user to set the threshold for simplification (instead of using a predefined value).
- Have added the pre-processing steps of dissolving and converting multiparts to singleparts in the plug-in itself after testing the algorithms using models. These algorithms of processing toolbox are called within the SimplificationAlgorithm.
- In the coming week I'll be trying to add the tests suites for the plug-in which will be helpful for testing the current features as well as for future testing purpose.
- Tested the working of algorithm on various data-sets and checked their result.
- Implemented a basic unit test for checking whether our algorithm is running correctly as expected by counting the features and checking the field names and value. Code can be seen at SchematizationTest.
- In the coming weeks I'll try to implement different constraints over the now simplified network starting with the direction/angular constraint.
- Discussed the ways to implement angle constraint for our project with the mentors.
- Working on different approaches and will try to figure out which one would be better suited for the project.
- Implemented the algorithm for the approach of putting angle constraints for lines as was discussed with the mentors earlier. The approach does what was expected and is giving desired results in most cases but still there are some parts where the change in angle is resulting in topological inaccuracies.
- Will discuss with the mentors ways to handle the inaccuracies.
- After discussion it was decided that we'll try to put in checking mechanisms for the kind of errors/inaccuracies being encountered.
- Also handled some issues with the algorithm implemented.
- Will try to finish the implementation of this checking mechanism in the coming week.
- Finished the implementation of checking mechanism to handle the inaccuracies.
- Will be updating the code in the plug-in. As of now it is the form of scripts.
- Will discuss with the mentor regarding any issues with the current progress.
- Solved some major bugs after discussing with the mentors and now the results are better than before.
- In the process of updating the code from the script to the plug-in.
- For the coming week, will do testing on various datasets. Also, will be working on refining and cleaning the code.
- Below are the images of the original input layer, the layer after simplification and the output after applying angle constraints.
- Successfully updated the plug-in with the angle constraint algorithm.
- Will work on final documentation and report drafting.
- Documentation Completed.
- Draft of the project report submitted to the mentor for final evaluation.