[postgis-tickets] r14716 - Test data and figures for ST_ClusterKMeans

Regina Obe lr at pcorp.us
Sat Feb 27 09:32:02 PST 2016


Author: robe
Date: 2016-02-27 09:32:02 -0800 (Sat, 27 Feb 2016)
New Revision: 14716

Added:
   trunk/doc/html/image_src/st_clusterkmeans01.wkt
   trunk/doc/html/image_src/st_clusterkmeans02.wkt
Modified:
   trunk/doc/html/image_src/Makefile.in
   trunk/doc/reference_measure.xml
Log:
Test data and figures for ST_ClusterKMeans

Modified: trunk/doc/html/image_src/Makefile.in
===================================================================
--- trunk/doc/html/image_src/Makefile.in	2016-02-27 16:19:49 UTC (rev 14715)
+++ trunk/doc/html/image_src/Makefile.in	2016-02-27 17:32:02 UTC (rev 14716)
@@ -37,6 +37,8 @@
 	../images/st_buildarea02.png \
 	../images/st_closestpoint01.png \
 	../images/st_closestpoint02.png \
+	../images/st_clusterkmeans01.png \
+	../images/st_clusterkmeans02.png \
 	../images/st_centroid01.png \
 	../images/st_centroid02.png \
 	../images/st_centroid03.png \

Added: trunk/doc/html/image_src/st_clusterkmeans01.wkt
===================================================================
--- trunk/doc/html/image_src/st_clusterkmeans01.wkt	                        (rev 0)
+++ trunk/doc/html/image_src/st_clusterkmeans01.wkt	2016-02-27 17:32:02 UTC (rev 14716)
@@ -0,0 +1,13 @@
+Style2-thinline;POLYGON((10 60,10 125.783386230469,75.7833862304688 125.783386230469,75.7833862304688 60,50 60,10 60))
+Style2-thinline;POLYGON((75.7833862304688 60,75.7833862304688 92.8916931152344,108.675079345703 92.8916931152344,108.675079345703 61.6355782426027,105.60746371632 60.7300815406388,98 60,75.7833862304688 60))
+Style2-thinline;POLYGON((108.675079345703 61.6355782426027,108.675079345703 76.4458465576172,130.257366799736 76.4458465576172,125.713274243959 71.1560330280473,119.721714690708 66.4118010173891,112.937223991122 62.8936752097563,108.675079345703 61.6355782426027))
+Style2-thinline;POLYGON((108.675079345703 76.4458465576172,108.675079345703 92.8916931152344,125.12092590332 92.8916931152344,125.12092590332 76.4458465576172,108.675079345703 76.4458465576172))
+Style2-thinline;POLYGON((125.12092590332 76.4458465576172,125.12092590332 84.6687698364258,134.845007596642 84.6687698364258,134.479663763751 83.5916444552268,130.693186299402 76.9531874309565,130.257366799736 76.4458465576172,125.12092590332 76.4458465576172))
+Style2-thinline;POLYGON((125.12092590332 84.6687698364258,125.12092590332 92.8916931152344,137.216018090238 92.8916931152344,136.934484771969 90.829073354271,134.845007596642 84.6687698364258,125.12092590332 84.6687698364258))
+Style2-thinline;POLYGON((75.7833862304688 92.8916931152344,75.7833862304688 125.783386230469,139.063322659449 125.783386230469,137.968038348872 98.4012784660451,137.216018090238 92.8916931152344,75.7833862304688 92.8916931152344))
+Style2-thinline;POLYGON((10 125.783386230469,10 140,42.8916931152344 140,42.8916931152344 125.783386230469,10 125.783386230469))
+Style2-thinline;POLYGON((42.8916931152344 125.783386230469,42.8916931152344 140,59.5680127897702 140,59.6571821012937 142.229232788086,75.7833862304688 142.229232788086,75.7833862304688 125.783386230469,42.8916931152344 125.783386230469))
+Style2-thinline;POLYGON((59.6571821012937 142.229232788086,60.0319616511284 151.598721533955,60.3150159635984 158.675079345703,75.7833862304688 158.675079345703,75.7833862304688 142.229232788086,59.6571821012937 142.229232788086))
+Style2-thinline;POLYGON((60.3150159635984 158.675079345703,61.6306831850833 191.566759882826,75.7833862304688 191.000651761011,75.7833862304688 158.675079345703,60.3150159635984 158.675079345703))
+Style2-thinline;POLYGON((75.7833862304688 125.783386230469,75.7833862304688 191.000651761011,141.566759882826 188.369316814917,139.063322659449 125.783386230469,75.7833862304688 125.783386230469))
+

Added: trunk/doc/html/image_src/st_clusterkmeans02.wkt
===================================================================
--- trunk/doc/html/image_src/st_clusterkmeans02.wkt	                        (rev 0)
+++ trunk/doc/html/image_src/st_clusterkmeans02.wkt	2016-02-27 17:32:02 UTC (rev 14716)
@@ -0,0 +1,12 @@
+Style1;POLYGON((10 60,10 125.783386230469,75.7833862304688 125.783386230469,75.7833862304688 60,50 60,10 60))
+Style2;POLYGON((75.7833862304688 60,75.7833862304688 92.8916931152344,108.675079345703 92.8916931152344,108.675079345703 61.6355782426027,105.60746371632 60.7300815406388,98 60,75.7833862304688 60))
+Style2;POLYGON((108.675079345703 61.6355782426027,108.675079345703 76.4458465576172,130.257366799736 76.4458465576172,125.713274243959 71.1560330280473,119.721714690708 66.4118010173891,112.937223991122 62.8936752097563,108.675079345703 61.6355782426027))
+Style2;POLYGON((108.675079345703 76.4458465576172,108.675079345703 92.8916931152344,125.12092590332 92.8916931152344,125.12092590332 76.4458465576172,108.675079345703 76.4458465576172))
+Style2;POLYGON((125.12092590332 76.4458465576172,125.12092590332 84.6687698364258,134.845007596642 84.6687698364258,134.479663763751 83.5916444552268,130.693186299402 76.9531874309565,130.257366799736 76.4458465576172,125.12092590332 76.4458465576172))
+Style2;POLYGON((125.12092590332 84.6687698364258,125.12092590332 92.8916931152344,137.216018090238 92.8916931152344,136.934484771969 90.829073354271,134.845007596642 84.6687698364258,125.12092590332 84.6687698364258))
+Style2;POLYGON((75.7833862304688 92.8916931152344,75.7833862304688 125.783386230469,139.063322659449 125.783386230469,137.968038348872 98.4012784660451,137.216018090238 92.8916931152344,75.7833862304688 92.8916931152344))
+Style3;POLYGON((10 125.783386230469,10 140,42.8916931152344 140,42.8916931152344 125.783386230469,10 125.783386230469))
+Style3;POLYGON((42.8916931152344 125.783386230469,42.8916931152344 140,59.5680127897702 140,59.6571821012937 142.229232788086,75.7833862304688 142.229232788086,75.7833862304688 125.783386230469,42.8916931152344 125.783386230469))
+Style3;POLYGON((59.6571821012937 142.229232788086,60.0319616511284 151.598721533955,60.3150159635984 158.675079345703,75.7833862304688 158.675079345703,75.7833862304688 142.229232788086,59.6571821012937 142.229232788086))
+Style3;POLYGON((60.3150159635984 158.675079345703,61.6306831850833 191.566759882826,75.7833862304688 191.000651761011,75.7833862304688 158.675079345703,60.3150159635984 158.675079345703))
+Style4;POLYGON((75.7833862304688 125.783386230469,75.7833862304688 191.000651761011,141.566759882826 188.369316814917,139.063322659449 125.783386230469,75.7833862304688 125.783386230469))

Modified: trunk/doc/reference_measure.xml
===================================================================
--- trunk/doc/reference_measure.xml	2016-02-27 16:19:49 UTC (rev 14715)
+++ trunk/doc/reference_measure.xml	2016-02-27 17:32:02 UTC (rev 14716)
@@ -1211,10 +1211,83 @@
 
     <refsection>
       <title>Examples</title>
-		    <programlisting>
-SELECT ST_ClusterKMeans(geom, 5) over (), geom, parcel_id 
+      		<para>Generate dummy set of parcels for examples</para>
+      		<programlisting>CREATE TABLE parcels AS 
+SELECT lpad((row_number() over())::text,3,'0') As parcel_id, geom, 
+	('{residential, commercial}'::text[])[1 + mod(row_number()OVER(),2)] As type
+FROM 
+    ST_Subdivide(ST_Buffer('LINESTRING(50 100, 98 100, 100 150)'::geometry,
+    40, 'endcap=square'),8) As geom;
+</programlisting>
+    
+    	<informaltable>
+			  <tgroup cols="1">
+				<tbody>
+				  <row>
+				  	<entry>
+						<para><informalfigure>
+						<mediaobject>
+						  <imageobject>
+							<imagedata fileref="images/st_clusterkmean01.png" />
+						  </imageobject>
+						  <caption><para>Original Parcels</para></caption>
+						</mediaobject>
+						</informalfigure>
+						</para>
+					</entry>
+					<entry><para><informalfigure>
+						<mediaobject>
+						  <imageobject>
+							<imagedata fileref="images/st_clusterkmean02.png" />
+						  </imageobject>
+						  <caption><para>Parcels color-coded by cluster number (cid)</para></caption>
+						</mediaobject>
+					  </informalfigure>
+						<programlisting>SELECT ST_ClusterKMeans(geom, 5) OVER() AS cid, parcel_id, geom 
 FROM parcels;
+-- result
+ cid | parcel_id |        geom
+-----+-----------+------------------------
+   0 | 001       | 01030000000100000006..
+   1 | 002       | 01030000000100000007..
+   1 | 003       | 01030000000100000007..
+   1 | 004       | 01030000000100000005..
+   1 | 005       | 01030000000100000007..
+   1 | 006       | 01030000000100000006..
+   1 | 007       | 01030000000100000006..
+   2 | 008       | 01030000000100000005..
+   2 | 009       | 01030000000100000007..
+   2 | 010       | 01030000000100000006..
+   2 | 011       | 01030000000100000005..
+   3 | 012       | 01030000000100000005..
+(12 rows)</programlisting>
+					</para></entry>
+				  </row>
+			</tbody>
+			</tgroup>
+		</informaltable>
+
+		    <programlisting> -- Partitioning parcel clusters by type
+SELECT ST_ClusterKMeans(geom,3) over (PARTITION BY type) AS cid, parcel_id, type
+FROM parcels;
+-- result
+ cid | parcel_id |    type
+-----+-----------+-------------
+   0 | 001       | commercial
+   1 | 003       | commercial
+   1 | 005       | commercial
+   1 | 007       | commercial
+   2 | 009       | commercial
+   2 | 011       | commercial
+   1 | 010       | residential
+   1 | 002       | residential
+   0 | 008       | residential
+   2 | 004       | residential
+   2 | 012       | residential
+   2 | 006       | residential
+(12 rows)
 </programlisting>
+
     </refsection>
 
     <refsection>
@@ -1222,7 +1295,7 @@
           <para>
               <xref linkend="ST_ClusterDBSCAN"/>,
               <xref linkend="ST_ClusterIntersecting" />,
-              <xref linkend="ST_ClusterWithin" /> 
+              <xref linkend="ST_ClusterWithin" />, <xref linkend="ST_Subdivide" />
           </para>
 	  </refsection>
 	</refentry>  



More information about the postgis-tickets mailing list