]> granicus.if.org Git - postgis/commitdiff
Test data and figures for ST_ClusterKMeans
authorRegina Obe <lr@pcorp.us>
Sat, 27 Feb 2016 17:32:02 +0000 (17:32 +0000)
committerRegina Obe <lr@pcorp.us>
Sat, 27 Feb 2016 17:32:02 +0000 (17:32 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@14716 b70326c6-7e19-0410-871a-916f4a2858ee

doc/html/image_src/Makefile.in
doc/html/image_src/st_clusterkmeans01.wkt [new file with mode: 0644]
doc/html/image_src/st_clusterkmeans02.wkt [new file with mode: 0644]
doc/reference_measure.xml

index 521331196f3260a032a3a945593f7cd86ea451fc..18ca3a0ac2cae0cb43824f8883b484af16d5b016 100644 (file)
@@ -37,6 +37,8 @@ IMAGES= \
        ../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 \
diff --git a/doc/html/image_src/st_clusterkmeans01.wkt b/doc/html/image_src/st_clusterkmeans01.wkt
new file mode 100644 (file)
index 0000000..cae9af2
--- /dev/null
@@ -0,0 +1,13 @@
+Style2-thinline;POLYGON((10 60,10 125.783386230469,75.7833862304688 125.783386230469,75.7833862304688 60,50 60,10 60))\r
+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))\r
+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))\r
+Style2-thinline;POLYGON((108.675079345703 76.4458465576172,108.675079345703 92.8916931152344,125.12092590332 92.8916931152344,125.12092590332 76.4458465576172,108.675079345703 76.4458465576172))\r
+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))\r
+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))\r
+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))\r
+Style2-thinline;POLYGON((10 125.783386230469,10 140,42.8916931152344 140,42.8916931152344 125.783386230469,10 125.783386230469))\r
+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))\r
+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))\r
+Style2-thinline;POLYGON((60.3150159635984 158.675079345703,61.6306831850833 191.566759882826,75.7833862304688 191.000651761011,75.7833862304688 158.675079345703,60.3150159635984 158.675079345703))\r
+Style2-thinline;POLYGON((75.7833862304688 125.783386230469,75.7833862304688 191.000651761011,141.566759882826 188.369316814917,139.063322659449 125.783386230469,75.7833862304688 125.783386230469))\r
+\r
diff --git a/doc/html/image_src/st_clusterkmeans02.wkt b/doc/html/image_src/st_clusterkmeans02.wkt
new file mode 100644 (file)
index 0000000..114e02c
--- /dev/null
@@ -0,0 +1,12 @@
+Style1;POLYGON((10 60,10 125.783386230469,75.7833862304688 125.783386230469,75.7833862304688 60,50 60,10 60))\r
+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))\r
+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))\r
+Style2;POLYGON((108.675079345703 76.4458465576172,108.675079345703 92.8916931152344,125.12092590332 92.8916931152344,125.12092590332 76.4458465576172,108.675079345703 76.4458465576172))\r
+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))\r
+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))\r
+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))\r
+Style3;POLYGON((10 125.783386230469,10 140,42.8916931152344 140,42.8916931152344 125.783386230469,10 125.783386230469))\r
+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))\r
+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))\r
+Style3;POLYGON((60.3150159635984 158.675079345703,61.6306831850833 191.566759882826,75.7833862304688 191.000651761011,75.7833862304688 158.675079345703,60.3150159635984 158.675079345703))\r
+Style4;POLYGON((75.7833862304688 125.783386230469,75.7833862304688 191.000651761011,141.566759882826 188.369316814917,139.063322659449 125.783386230469,75.7833862304688 125.783386230469))\r
index 149c55746a88829ee8dac8fc0fac81d8a37156f8..02599ba3fe63973ec301b916461d87dde79e112d 100644 (file)
@@ -1211,10 +1211,83 @@ GEOMETRYCOLLECTION(LINESTRING(6 6,7 7))
 
     <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 @@ FROM parcels;
           <para>
               <xref linkend="ST_ClusterDBSCAN"/>,
               <xref linkend="ST_ClusterIntersecting" />,
-              <xref linkend="ST_ClusterWithin" /> 
+              <xref linkend="ST_ClusterWithin" />, <xref linkend="ST_Subdivide" />
           </para>
          </refsection>
        </refentry>