From: Regina Obe Date: Sat, 27 Feb 2016 17:32:02 +0000 (+0000) Subject: Test data and figures for ST_ClusterKMeans X-Git-Tag: 2.3.0beta1~212 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=937292c60171881c1149b7452210a866cadea0fb;p=postgis Test data and figures for ST_ClusterKMeans git-svn-id: http://svn.osgeo.org/postgis/trunk@14716 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/html/image_src/Makefile.in b/doc/html/image_src/Makefile.in index 521331196..18ca3a0ac 100644 --- a/doc/html/image_src/Makefile.in +++ b/doc/html/image_src/Makefile.in @@ -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 index 000000000..cae9af253 --- /dev/null +++ b/doc/html/image_src/st_clusterkmeans01.wkt @@ -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)) + diff --git a/doc/html/image_src/st_clusterkmeans02.wkt b/doc/html/image_src/st_clusterkmeans02.wkt new file mode 100644 index 000000000..114e02cf7 --- /dev/null +++ b/doc/html/image_src/st_clusterkmeans02.wkt @@ -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)) diff --git a/doc/reference_measure.xml b/doc/reference_measure.xml index 149c55746..02599ba3f 100644 --- a/doc/reference_measure.xml +++ b/doc/reference_measure.xml @@ -1211,10 +1211,83 @@ GEOMETRYCOLLECTION(LINESTRING(6 6,7 7)) Examples - -SELECT ST_ClusterKMeans(geom, 5) over (), geom, parcel_id + Generate dummy set of parcels for examples + 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; + + + + + + + + + + + + + Original Parcels + + + + + + + + + + Parcels color-coded by cluster number (cid) + + + 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) + + + + + + + -- 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) + @@ -1222,7 +1295,7 @@ FROM parcels; , , - + ,