Skip to content
Permalink
Browse files

[processing] Add a cluster size attribute to the kmean cluster algorithm

  • Loading branch information
nirvn committed Aug 27, 2020
1 parent 63bca85 commit af81515831004747ee5972befa083ed796425f21
@@ -15,41 +15,48 @@
<ogr:kmeans_lines fid="lines.0">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,2 9,2 9,3 11,5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>3</ogr:CLUSTER_SIZE>
</ogr:kmeans_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:kmeans_lines fid="lines.1">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>-1,-1 1,-1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:CLUSTER_ID>0</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>3</ogr:CLUSTER_SIZE>
</ogr:kmeans_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:kmeans_lines fid="lines.2">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>2,0 2,2 3,2 3,3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:CLUSTER_ID>0</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>3</ogr:CLUSTER_SIZE>
</ogr:kmeans_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:kmeans_lines fid="lines.3">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>3,1 5,1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:CLUSTER_ID>0</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>3</ogr:CLUSTER_SIZE>
</ogr:kmeans_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:kmeans_lines fid="lines.4">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>7,-3 10,-3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>3</ogr:CLUSTER_SIZE>
</ogr:kmeans_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:kmeans_lines fid="lines.5">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,-3 10,1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>3</ogr:CLUSTER_SIZE>
</ogr:kmeans_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:kmeans_lines fid="lines.6">
<ogr:CLUSTER_ID xsi:nil="true"/>
<ogr:CLUSTER_SIZE xsi:nil="true"/>
</ogr:kmeans_lines>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -23,6 +23,13 @@
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLUSTER_SIZE" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
@@ -17,6 +17,7 @@
<ogr:id>1</ogr:id>
<ogr:id2>2</ogr:id2>
<ogr:CLUSTER_ID>2</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>6</ogr:CLUSTER_SIZE>
</ogr:kmeans_points_3>
</gml:featureMember>
<gml:featureMember>
@@ -25,6 +26,7 @@
<ogr:id>2</ogr:id>
<ogr:id2>1</ogr:id2>
<ogr:CLUSTER_ID>2</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>6</ogr:CLUSTER_SIZE>
</ogr:kmeans_points_3>
</gml:featureMember>
<gml:featureMember>
@@ -33,6 +35,7 @@
<ogr:id>3</ogr:id>
<ogr:id2>0</ogr:id2>
<ogr:CLUSTER_ID>2</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>6</ogr:CLUSTER_SIZE>
</ogr:kmeans_points_3>
</gml:featureMember>
<gml:featureMember>
@@ -41,6 +44,7 @@
<ogr:id>4</ogr:id>
<ogr:id2>2</ogr:id2>
<ogr:CLUSTER_ID>2</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>6</ogr:CLUSTER_SIZE>
</ogr:kmeans_points_3>
</gml:featureMember>
<gml:featureMember>
@@ -49,6 +53,7 @@
<ogr:id>5</ogr:id>
<ogr:id2>1</ogr:id2>
<ogr:CLUSTER_ID>2</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>6</ogr:CLUSTER_SIZE>
</ogr:kmeans_points_3>
</gml:featureMember>
<gml:featureMember>
@@ -57,6 +62,7 @@
<ogr:id>6</ogr:id>
<ogr:id2>0</ogr:id2>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>1</ogr:CLUSTER_SIZE>
</ogr:kmeans_points_3>
</gml:featureMember>
<gml:featureMember>
@@ -65,6 +71,7 @@
<ogr:id>7</ogr:id>
<ogr:id2>0</ogr:id2>
<ogr:CLUSTER_ID>0</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>2</ogr:CLUSTER_SIZE>
</ogr:kmeans_points_3>
</gml:featureMember>
<gml:featureMember>
@@ -73,6 +80,7 @@
<ogr:id>8</ogr:id>
<ogr:id2>0</ogr:id2>
<ogr:CLUSTER_ID>0</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>2</ogr:CLUSTER_SIZE>
</ogr:kmeans_points_3>
</gml:featureMember>
<gml:featureMember>
@@ -81,6 +89,7 @@
<ogr:id>9</ogr:id>
<ogr:id2>0</ogr:id2>
<ogr:CLUSTER_ID>2</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>6</ogr:CLUSTER_SIZE>
</ogr:kmeans_points_3>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -37,6 +37,13 @@
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLUSTER_SIZE" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
@@ -17,6 +17,7 @@
<ogr:id>1</ogr:id>
<ogr:id2>2</ogr:id2>
<ogr:CLUSTER_ID5>2</ogr:CLUSTER_ID5>
<ogr:CLUSTER_SIZE5>3</ogr:CLUSTER_SIZE5>
</ogr:kmeans_points_5>
</gml:featureMember>
<gml:featureMember>
@@ -25,6 +26,7 @@
<ogr:id>2</ogr:id>
<ogr:id2>1</ogr:id2>
<ogr:CLUSTER_ID5>2</ogr:CLUSTER_ID5>
<ogr:CLUSTER_SIZE5>3</ogr:CLUSTER_SIZE5>
</ogr:kmeans_points_5>
</gml:featureMember>
<gml:featureMember>
@@ -33,6 +35,7 @@
<ogr:id>3</ogr:id>
<ogr:id2>0</ogr:id2>
<ogr:CLUSTER_ID5>2</ogr:CLUSTER_ID5>
<ogr:CLUSTER_SIZE5>3</ogr:CLUSTER_SIZE5>
</ogr:kmeans_points_5>
</gml:featureMember>
<gml:featureMember>
@@ -41,6 +44,7 @@
<ogr:id>4</ogr:id>
<ogr:id2>2</ogr:id2>
<ogr:CLUSTER_ID5>4</ogr:CLUSTER_ID5>
<ogr:CLUSTER_SIZE5>2</ogr:CLUSTER_SIZE5>
</ogr:kmeans_points_5>
</gml:featureMember>
<gml:featureMember>
@@ -49,6 +53,7 @@
<ogr:id>5</ogr:id>
<ogr:id2>1</ogr:id2>
<ogr:CLUSTER_ID5>4</ogr:CLUSTER_ID5>
<ogr:CLUSTER_SIZE5>2</ogr:CLUSTER_SIZE5>
</ogr:kmeans_points_5>
</gml:featureMember>
<gml:featureMember>
@@ -57,6 +62,7 @@
<ogr:id>6</ogr:id>
<ogr:id2>0</ogr:id2>
<ogr:CLUSTER_ID5>1</ogr:CLUSTER_ID5>
<ogr:CLUSTER_SIZE5>1</ogr:CLUSTER_SIZE5>
</ogr:kmeans_points_5>
</gml:featureMember>
<gml:featureMember>
@@ -65,6 +71,7 @@
<ogr:id>7</ogr:id>
<ogr:id2>0</ogr:id2>
<ogr:CLUSTER_ID5>0</ogr:CLUSTER_ID5>
<ogr:CLUSTER_SIZE5>2</ogr:CLUSTER_SIZE5>
</ogr:kmeans_points_5>
</gml:featureMember>
<gml:featureMember>
@@ -73,6 +80,7 @@
<ogr:id>8</ogr:id>
<ogr:id2>0</ogr:id2>
<ogr:CLUSTER_ID5>0</ogr:CLUSTER_ID5>
<ogr:CLUSTER_SIZE5>2</ogr:CLUSTER_SIZE5>
</ogr:kmeans_points_5>
</gml:featureMember>
<gml:featureMember>
@@ -81,6 +89,7 @@
<ogr:id>9</ogr:id>
<ogr:id2>0</ogr:id2>
<ogr:CLUSTER_ID5>3</ogr:CLUSTER_ID5>
<ogr:CLUSTER_SIZE5>1</ogr:CLUSTER_SIZE5>
</ogr:kmeans_points_5>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -37,6 +37,13 @@
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLUSTER_SIZE5" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
@@ -18,6 +18,7 @@
<ogr:intval>33</ogr:intval>
<ogr:floatval>44.123456</ogr:floatval>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>4</ogr:CLUSTER_SIZE>
</ogr:kmeans_polys>
</gml:featureMember>
<gml:featureMember>
@@ -27,6 +28,7 @@
<ogr:intval>-33</ogr:intval>
<ogr:floatval>0</ogr:floatval>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>4</ogr:CLUSTER_SIZE>
</ogr:kmeans_polys>
</gml:featureMember>
<gml:featureMember>
@@ -36,6 +38,7 @@
<ogr:intval xsi:nil="true"/>
<ogr:floatval>0.123</ogr:floatval>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>4</ogr:CLUSTER_SIZE>
</ogr:kmeans_polys>
</gml:featureMember>
<gml:featureMember>
@@ -45,6 +48,7 @@
<ogr:intval>0</ogr:intval>
<ogr:floatval xsi:nil="true"/>
<ogr:CLUSTER_ID>0</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>1</ogr:CLUSTER_SIZE>
</ogr:kmeans_polys>
</gml:featureMember>
<gml:featureMember>
@@ -53,6 +57,7 @@
<ogr:intval>120</ogr:intval>
<ogr:floatval>-100291.43213</ogr:floatval>
<ogr:CLUSTER_ID xsi:nil="true"/>
<ogr:CLUSTER_SIZE xsi:nil="true"/>
</ogr:kmeans_polys>
</gml:featureMember>
<gml:featureMember>
@@ -62,6 +67,7 @@
<ogr:intval>2</ogr:intval>
<ogr:floatval>3.33</ogr:floatval>
<ogr:CLUSTER_ID>1</ogr:CLUSTER_ID>
<ogr:CLUSTER_SIZE>4</ogr:CLUSTER_SIZE>
</ogr:kmeans_polys>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -43,6 +43,13 @@
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLUSTER_SIZE" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
@@ -768,6 +768,7 @@ tests:
params:
CLUSTERS: 5
FIELD_NAME: CLUSTER_ID5
SIZE_FIELD_NAME: CLUSTER_SIZE5
INPUT:
name: points.gml
type: vector

0 comments on commit af81515

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