[postgis-users] Union, but need to exclude any void

Toby Rainthorpe toby.rainthorpe at frsltd.co.uk
Sat Nov 1 15:59:29 PDT 2008


Thanks for help, but it still looks like union fills in the gap so to  
speak, any more ideas?

SELECT ST_AsEWKT(ST_Union(the_geom)) as the_geom
FROM postcode_sectors
WHERE postarea = 'LN'

"SRID=4269;POLYGON((0.194430850648443  
53.213308161178,0.169714736355569 53.2124120839752,0.0834492984598471  
53.2348844372266,0.0208307835734331  
53.2478135975227,-0.0126938531249155  
53.1710150547887,-0.13716904881661 53.1418544045366,-0.150749526290076  
53.1243892073786,-0.130710137006856  
53.0239835120991,-0.229285061035197  
53.0038950480853,-0.338497757654447  
53.0609112327498,-0.408675738441825 53.055621865059,-0.452241950934627  
53.0579499714055,-0.52047527802287 53.0487392813369,-0.660214167307015  
53.0546658032031,-0.714807399468163  
53.0584148660486,-0.699290317426583  
53.0756434022022,-0.716927624544292  
53.1105928908201,-0.674018446595594  
53.2187206490539,-0.668182682830745  
53.2552110975952,-0.775752949336526  
53.2466816979897,-0.764778898530289  
53.2691344556123,-0.751456893012603  
53.3202408495374,-0.567075865458079  
53.3529438083222,-0.549064460589285  
53.4257467252708,-0.461252440918993  
53.4290079476242,-0.459280037729661  
53.4356804144195,-0.491910432874966 53.497600359203,-0.41389940584748  
53.5500565803702,-0.310449877650045  
53.5267476031091,-0.219352544114183  
53.5272954168687,-0.215026390840363  
53.5063814691382,-0.203265094143773 53.466744705434,-0.122544300870874  
53.4548941206983,0.0264268890418949 53.4620080919002,0.083849617015283  
53.496544395631,0.228359151391426 53.408400422663,0.268028563946318  
53.342544544341,0.302708719734213 53.2940795243504,0.321850405882593  
53.2715163271867,0.234840151689661 53.1942224753385,0.194430850648443  
53.213308161178))"

SELECT ST_AsEWKT(ST_Union(the_geom)) as the_geom
FROM postcode_sectors
WHERE com_dist = 'LN1'

"SRID=4269;POLYGON((-0.567075865458079  
53.3529438083222,-0.541250872030082 53.3316560575988,-0.53867243559146  
53.2902048795337,-0.538372820842824  
53.2545802514289,-0.536621729986015  
53.2443903523506,-0.537587144360509 53.23365835124,-0.539261287526225  
53.2285001962972,-0.542511758566372  
53.2276409117944,-0.567956817933028 53.233334871246,-0.570638045173646  
53.2342660459289,-0.574252637693809  
53.2359726746639,-0.640114978977996  
53.2538783112452,-0.668182682830745  
53.2552110975952,-0.775752949336526  
53.2466816979897,-0.764778898530289  
53.2691344556123,-0.751456893012603  
53.3202408495374,-0.567075865458079 53.3529438083222))"

SELECT postarea, com_dist, gid
FROM postcode_sectors
WHERE  postarea = 'LN' AND NOT com_dist = 'LN1'
ORDER BY postarea, com_dist

"LN";"LN10";4942
"LN";"LN10";4941
"LN";"LN11";4946
"LN";"LN11";4943
"LN";"LN11";4944
"LN";"LN11";4945
"LN";"LN12";4947
"LN";"LN12";4948
"LN";"LN13";4949
"LN";"LN13";4950
"LN";"LN2";4912
"LN";"LN2";4914
"LN";"LN2";4915
"LN";"LN2";4913
"LN";"LN2";4916
"LN";"LN3";4918
"LN";"LN3";4917
"LN";"LN4";4922
"LN";"LN4";4920
"LN";"LN4";4919
"LN";"LN4";4921
"LN";"LN5";4926
"LN";"LN5";4923
"LN";"LN5";4924
"LN";"LN5";4925
"LN";"LN6";4927
"LN";"LN6";4932
"LN";"LN6";4928
"LN";"LN6";4929
"LN";"LN6";4931
"LN";"LN6";4933
"LN";"LN6";4930
"LN";"LN7";4934
"LN";"LN8";4937
"LN";"LN8";4936
"LN";"LN8";4935
"LN";"LN8";4938
"LN";"LN9";4939
"LN";"LN9";4940




From: 	lr at pcorp.us
Subject: 	RE: [postgis-users] Union, but need to exclude any void
Date: 	1 November 2008 19:23:09 GMT
To: 	postgis-users at postgis.refractions.net
Reply-To: 	postgis-users at postgis.refractions.net

Toby,
I agree with Stanley that it is probably not a ST_Union problem.  I'm  
guessing there is something wrong with your WHERE clause.  Keep in  
mind PostgreSQL is case sensitive so if by chance
you had something like ln1  instead of LN1 in the com_dist field, then  
the ln1s would be picked up as NOT ....

To rule out ST_Union as the culprit, can you do a simple attribute query

SELECT postarea, com_dist, gid
FROM postcode_sectors
WHERE  postarea = 'LN' AND NOT com_dist = 'LN1'
ORDER BY postarea, com_dist

Also I tend to do com_dist <> 'LN1' , but that shouldn't matter.

Hope that helps,
Regina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20081101/6b66c311/attachment.html>


More information about the postgis-users mailing list