mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-04 00:30:59 -05:00
Adds a native k-means clustering algorithm. Based on a port of PostGIS' ST_ClusterKMeans function, this new algorithm adds a new cluster ID field to a set of input features identify the feature's cluster based on the k-means clustering approach. If non-point geometries are used as input, the clustering is based off the centroid of the input geometries.
56 lines
2.5 KiB
XML
56 lines
2.5 KiB
XML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<ogr:FeatureCollection
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://ogr.maptools.org/ kmeans_lines.xsd"
|
|
xmlns:ogr="http://ogr.maptools.org/"
|
|
xmlns:gml="http://www.opengis.net/gml">
|
|
<gml:boundedBy>
|
|
<gml:Box>
|
|
<gml:coord><gml:X>-1</gml:X><gml:Y>-3</gml:Y></gml:coord>
|
|
<gml:coord><gml:X>11</gml:X><gml:Y>5</gml:Y></gml:coord>
|
|
</gml:Box>
|
|
</gml:boundedBy>
|
|
|
|
<gml:featureMember>
|
|
<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: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: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: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: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: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:kmeans_lines>
|
|
</gml:featureMember>
|
|
<gml:featureMember>
|
|
<ogr:kmeans_lines fid="lines.6">
|
|
<ogr:CLUSTER_ID xsi:nil="true"/>
|
|
</ogr:kmeans_lines>
|
|
</gml:featureMember>
|
|
</ogr:FeatureCollection>
|