Skip to content
Permalink
Browse files

Merge pull request #7626 from rudivs/kneighbour

[feature] Adapted k-neighbour concave hull plugin as QGIS 3 algorithm
  • Loading branch information
luipir committed Sep 14, 2018
2 parents 1192b63 + 8fa27e1 commit 8b07b4ed9e5072ea7e4b85b41d041385e21a826f
Showing with 1,086 additions and 2 deletions.
  1. +1 −0 images/images.qrc
  2. +134 −0 images/themes/default/algorithms/mAlgorithmConcaveHull.svg
  3. +7 −0 python/plugins/processing/algs/help/qgis.yaml
  4. +12 −2 python/plugins/processing/algs/qgis/ConcaveHull.py
  5. +551 −0 python/plugins/processing/algs/qgis/KNearestConcaveHull.py
  6. +2 −0 python/plugins/processing/algs/qgis/QgisAlgorithmProvider.py
  7. +24 −0 python/plugins/processing/tests/testdata/custom/points_duplicate.gml
  8. +23 −0 python/plugins/processing/tests/testdata/custom/points_duplicate.xsd
  9. +20 −0 python/plugins/processing/tests/testdata/expected/knearest_concave_hull_lines.gml
  10. +30 −0 python/plugins/processing/tests/testdata/expected/knearest_concave_hull_lines.xsd
  11. +20 −0 python/plugins/processing/tests/testdata/expected/knearest_concave_hull_multipoints.gml
  12. +30 −0 python/plugins/processing/tests/testdata/expected/knearest_concave_hull_multipoints.xsd
  13. +20 −0 python/plugins/processing/tests/testdata/expected/knearest_concave_hull_points_7.gml
  14. +30 −0 python/plugins/processing/tests/testdata/expected/knearest_concave_hull_points_7.xsd
  15. +21 −0 python/plugins/processing/tests/testdata/expected/knearest_concave_hull_points_id2.gml
  16. +37 −0 python/plugins/processing/tests/testdata/expected/knearest_concave_hull_points_id2.xsd
  17. +20 −0 python/plugins/processing/tests/testdata/expected/knearest_concave_hull_polys.gml
  18. +30 −0 python/plugins/processing/tests/testdata/expected/knearest_concave_hull_polys.xsd
  19. +74 −0 python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
@@ -92,6 +92,7 @@
<file>themes/default/algorithms/mAlgorithmExtractVertices.svg</file>
<file>themes/default/algorithms/mAlgorithmExtractLayerExtent.svg</file>
<file>themes/default/algorithms/mAlgorithmIntersect.svg</file>
<file>themes/default/algorithms/mAlgorithmConcaveHull.svg</file>
<file>themes/default/algorithms/mAlgorithmLineIntersections.svg</file>
<file>themes/default/algorithms/mAlgorithmLineToPolygon.svg</file>
<file>themes/default/algorithms/mAlgorithmMeanCoordinates.svg</file>
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24"
height="24"
id="svg2"
version="1.1"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="mAlgorithmConcaveHull.svg"
inkscape:export-filename="E:\0000200_Entwicklung\ConcaveHull_for_QGIS\concavehull\icon2.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="11.107168"
inkscape:cx="-0.38508957"
inkscape:cy="9.330254"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1160"
inkscape:window-height="795"
inkscape:window-x="296"
inkscape:window-y="42"
inkscape:window-maximized="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1028.3622)">
<path
style="fill:#7c96a8;fill-opacity:1;stroke:#517083;stroke-width:1.002;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="m 2.5017811,1034.7051 0.083121,6.8555 6.1509752,0.6314 4.4054287,8.2086 8.229007,-0.3608 1.246819,-14.2523 -5.901611,-5.4122 -10.5564036,0.09 z"
id="path3862"
inkscape:connector-curvature="0" />
<ellipse
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#4b4c4b;stroke-width:0.4566187;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2996"
cx="6.9774761"
cy="1030.8896"
rx="1.7713778"
ry="1.7711906" />
<ellipse
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#4b4c4b;stroke-width:0.4566187;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2996-1"
cx="17.646261"
cy="1031.0247"
rx="1.7713778"
ry="1.7711906" />
<ellipse
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#4b4c4b;stroke-width:0.4566187;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2996-1-7"
cx="21.607668"
cy="1035.9764"
rx="1.7713778"
ry="1.7711906" />
<ellipse
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#4b4c4b;stroke-width:0.4566187;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2996-1-7-4"
cx="2.5208948"
cy="1041.5585"
rx="1.7713778"
ry="1.7711906" />
<ellipse
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#4b4c4b;stroke-width:0.4566187;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2996-1-7-0"
cx="21.517637"
cy="1049.7512"
rx="1.7713778"
ry="1.7711906" />
<ellipse
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#4b4c4b;stroke-width:0.4566187;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2996-1-7-9"
cx="14.044984"
cy="1049.7513"
rx="1.7713778"
ry="1.7711906" />
<ellipse
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#4b4c4b;stroke-width:0.4566187;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2996-1-7-48"
cx="9.4533548"
cy="1042.2786"
rx="1.7713778"
ry="1.7711906" />
<ellipse
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#4b4c4b;stroke-width:0.4566187;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2996-1-7-8"
cx="18.636614"
cy="1043.6292"
rx="1.7713778"
ry="1.7711906" />
<ellipse
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#4b4c4b;stroke-width:0.4566187;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2996-1-7-2"
cx="13.684856"
cy="1036.6066"
rx="1.7713778"
ry="1.7711906" />
<ellipse
style="fill:#e6e6e6;fill-opacity:1;fill-rule:evenodd;stroke:#4b4c4b;stroke-width:0.4566187;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2996-1-7-45"
cx="2.7009585"
cy="1034.9861"
rx="1.7713778"
ry="1.7711906" />
</g>
</svg>
@@ -233,6 +233,13 @@ qgis:joinbylocationsummary: >
qgis:keepnbiggestparts: >
This algorithm takes a polygon layer and creates a new polygon layer in which multipart geometries have been removed, leaving only the n largest (in terms of area) parts.

qgis:knearestconcavehull: >
This algorithm generates a concave hull polygon from a set of points. If the input layer is a line or polygon layer, it will use the nodes.

The number of neighbours to consider determines the concaveness of the output polygon. A lower number will result in a concave hull that follows the points very closely, while a higher number will have a smoother shape. The minimum number of neighbour points to consider is 3. A value equal to or greater than the number of points will result in a convex hull.

If a field is selected, the algorithm will group the features in the input layer using unique values in that field and generate individual polygons in the output layer for each group.

qgis:lineintersections: >
This algorithm creates point features where the lines in the Intersect layer intersect the lines in the Input layer.

@@ -28,7 +28,8 @@
from qgis.PyQt.QtCore import QCoreApplication
from math import sqrt

from qgis.core import (QgsFeature,
from qgis.core import (QgsApplication,
QgsFeature,
QgsFeatureSink,
QgsWkbTypes,
QgsProcessing,
@@ -75,7 +76,16 @@ def name(self):
return 'concavehull'

def displayName(self):
return self.tr('Concave hull')
return self.tr('Concave hull (alpha shapes)')

def shortDescription(self):
return self.tr('Creates a concave hull using the alpha shapes algorithm.')

def icon(self):
return QgsApplication.getThemeIcon("/algorithms/mAlgorithmConcaveHull.svg")

def svgIconPath(self):
return QgsApplication.iconPath("/algorithms/mAlgorithmConcaveHull.svg")

def processAlgorithm(self, parameters, context, feedback):
layer = self.parameterAsSource(parameters, ConcaveHull.INPUT, context)

0 comments on commit 8b07b4e

Please sign in to comment.
You can’t perform that action at this time.