{{Аннотация|Tools for perform displamecement of points with same coordinates.}}

{{Аннотация|Tools for perform displamecement of points with same coordinates.}}

−

One of the problems we encountered while working on the "[http://www.forbes.ru/sobytiya/vlast/77338-izbiratelnaya-geografiya-moskvy Elections map]": several points — Election Commissions — may have same address and as result same coordinates. So this points become overlapped and only information for upper point was available.

+

One of the problems we encountered while working on the "[http://www.forbes.ru/sobytiya/vlast/77338-izbiratelnaya-geografiya-moskvy Elections map]": several points — Election Commissions — may have the same address and as result the same coordinates. So these points become overlapped and only information for upper point is available.

−

The oblivious solution of this issue — move overlapped points at small distance, that they all become visible. Moving all points by hands is not a good solution as we have too many overlapped points and it is diffcult to keep same distance between points. So we start looking for automated solution. First of all we remember about existing "Point displacement" renderer in QGIS (it is in core now). Unfortunatelly this renderer only works in render-time and don't update shapefile itself.

+

The obvious solution of this issue — move overlapped points at small distance, that they all become visible. Moving all points by hands is not an option if you have many and it is difficult to keep the same distance between points.

+

+

"Point displacement" renderer in QGIS only works in render-time and doesn't update features itself.

After all we developed a small script to solve this problem, and later also QGIS plugin based on it.

After all we developed a small script to solve this problem, and later also QGIS plugin based on it.

Строка 18:

Строка 20:

The simplest way to get all necessary components under OS Windows is to use OSGeo4W installer:

The simplest way to get all necessary components under OS Windows is to use OSGeo4W installer:

−

* [http://download.osgeo.org/osgeo4w/osgeo4w-setup.exe download] installer. If the previous link is not accessible, there is an [http://download2.osgeo.org/osgeo4w/osgeo4w-setup-it.exe alternative link] on a mirror website

Текущая версия на 13:45, 3 апреля 2016

One of the problems we encountered while working on the "Elections map": several points — Election Commissions — may have the same address and as result the same coordinates. So these points become overlapped and only information for upper point is available.

The obvious solution of this issue — move overlapped points at small distance, that they all become visible. Moving all points by hands is not an option if you have many and it is difficult to keep the same distance between points.

"Point displacement" renderer in QGIS only works in render-time and doesn't update features itself.

After all we developed a small script to solve this problem, and later also QGIS plugin based on it.

If you run Linux, then install all necessary packages using your package manager. In Ubuntu/Debian you need to install python-gdal package.

Extract the script from archieve and copy displacement.py into any directory in your PATH (for example, into C:\Tools\GIS<tt> or <tt>~/bin). To run the script under Windows, you need to open OSGeo4W shell and run the script from the shell.

There is no graphical interface for the script and it runs in console mode at the moment. It takes two arguments as input and output. Also there several options for tuning

displacement.py [OPTIONS] INPUT_FILE OUTPUT_FILE

INPUT_FILE — input point shapefile

OUTPUT_FILE — output file

Options:

-d DISTANCE, --distance=DISTANCE — displacement distance. IMPORTANT! It is necessary to use for distance same units as input shapefile used. For example, if shapefile in decimal degrees than distance also should be in decimal degrees.

-r, --rotate — flag option. If used then two overlapped points will be shifted in horizontal direscion, otherwise — in vertical direction. Default value is False, so points will be shifted points moved vertically.

-l FILE, --log=FILE — file where ID's of overlapped points with field values will be written. Used together with option "-f"

-f FIELD, --field=FIELD — name of the shapefile field, which value will be added to log file. Used only together with option "-l"

Script founds all points with same coordinates and then moves them in a circle with center in "original" position and using value of the "-d" option as radius. So script provides same result as "Point displacement" renderer in QGIS.

Here is result of the processing shapefile with this scrip (blue — original points, green — points after displacement, displacement distance ~10 m.).

Select input point layer with overlapped features from "Input vector layer" combobox. Set desired displacement distance using "Displacement distance" spinbox. IMPORTANT! displacement distance should be in same units as layer.

Enter output file name into "Output file" field. If checkbox "For two point case distribute horizontally (otherwise vertically)" is checked two overlapped points will be distributed horizontally, otherwise they will be distributed vertically. To load new shapefile as layer in project check "Add result to canvas".