<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Ballongtext Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";
mso-fareast-language:EN-US;}
span.BallongtextChar
{mso-style-name:"Ballongtext Char";
mso-style-priority:99;
mso-style-link:Ballongtext;
font-family:"Tahoma","sans-serif";}
span.E-postmall19
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.E-postmall20
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="SV" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">Sorry I found what was wrong;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Drop table if exists cutted; <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">CREATE TABLE "cutted" as WITH <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> blade AS ( <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> SELECT ST_MakeLine(ST_SetSRID(ST_MakePoint(180, -90),4326),ST_SetSRID(ST_MakePoint(180.000, 90), 4326)) AS geom)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">SELECT a.*, (ST_Dump(ST_Split(a.the_geom, b.geom))).geom FROM shifted AS a, blade AS b
</span><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#2A00FF;background:#E8F2FE;mso-fareast-language:SV">WHERE ST_Intersects(a.the_geom, b.geom)</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">UNION ALL <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">SELECT *, the_geom FROM shifted AS a WHERE NOT EXISTS (
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> SELECT 1 FROM blade AS b WHERE ST_Intersects(a.the_geom, b.geom)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">ALTER TABLE cutted DROP COLUMN IF EXISTS the_geom;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">ALTER TABLE cutted RENAME COLUMN geom TO the_geom;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";mso-fareast-language:SV">Från:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";mso-fareast-language:SV"> postgis-users
[mailto:postgis-users-bounces@lists.osgeo.org] <b>För </b>Malm, Paul (Operations AIM)<br>
<b>Skickat:</b> den 13 februari 2020 14:56<br>
<b>Till:</b> postgis-users@lists.osgeo.org<br>
<b>Ämne:</b> [postgis-users] help with a SQL Command<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal">Hi list!<o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">I have a problem with a sql command, I would be grateful if someone please could tell me what I’m doing wrong.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I have a polygon layer where some polygons exceeds the 180/-180 border.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I would like to cut the polygons with a line from 180,90 to 180,-90.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I’ve got this far:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Drop table if exists cutted; <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">CREATE TABLE "cutted" as WITH <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> blade AS ( <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> SELECT ST_MakeLine(ST_SetSRID(ST_MakePoint(180, -90),4326),ST_SetSRID(ST_MakePoint(180.000, 90), 4326)) AS geom)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">SELECT a.*, (ST_Dump(ST_Split(a.the_geom, b.geom))).geom FROM shifted AS a, blade AS b
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">UNION ALL <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">SELECT *, the_geom FROM shifted AS a WHERE NOT EXISTS (
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> SELECT 1 FROM blade AS b WHERE ST_Intersects(a.the_geom, b.geom)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">ALTER TABLE cutted DROP COLUMN IF EXISTS the_geom;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">ALTER TABLE cutted RENAME COLUMN geom TO the_geom;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-fareast-language:SV"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-fareast-language:SV"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">It cuts the exceeding polygons nice but the uncut objects are duplicated in the result layer (cutted).<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks,</span><span lang="EN-US" style="font-size:9.0pt;mso-fareast-language:SV">
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-fareast-language:SV"> </span><span style="font-size:9.0pt;mso-fareast-language:SV"><img width="132" height="107" id="Bild_x0020_1" src="cid:image001.jpg@01D5E281.690A7810" alt="2_LFV_engelsk_96"><o:p></o:p></span></p>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse">
<tbody>
<tr style="height:36.85pt">
<td width="420" valign="top" style="width:315.0pt;padding:0cm 0cm 0cm 2.25pt;height:36.85pt">
<p class="MsoNormal" style="margin-top:2.0pt;line-height:10.0pt;mso-line-height-rule:exactly">
<span lang="EN-US" style="font-size:9.0pt;color:#333333;mso-fareast-language:SV"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-top:2.0pt;line-height:10.0pt;mso-line-height-rule:exactly">
<b><span lang="EN-US" style="font-size:9.0pt;color:#333333;mso-fareast-language:SV"> Paul Malm</span></b><span lang="EN-US" style="font-size:9.0pt;color:#333333;mso-fareast-language:SV"><br>
<br>
Operations AIM</span><span lang="EN-US" style="font-size:9.0pt;color:#333333"><o:p></o:p></span></p>
</td>
</tr>
<tr style="height:24.1pt">
<td width="420" valign="top" style="width:315.0pt;padding:0cm 0cm 0cm 2.25pt;height:24.1pt">
<p class="MsoNormal" style="margin-bottom:12.0pt;line-height:9.0pt;mso-line-height-rule:exactly">
<span lang="EN-US" style="font-size:9.0pt;color:#333333;mso-fareast-language:SV"> Direct +46 (0)8 797 70 23 Mobile: +46 (0)708 601115<br>
paul.malm@lfv.se <o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:9.0pt;mso-line-height-rule:exactly"><span lang="EN-US" style="font-size:9.0pt;color:#333333;mso-fareast-language:SV"> </span><span style="font-size:9.0pt;color:#333333;mso-fareast-language:SV">Mail & Visit: Löjtnantsgatan
25, 115 50 Stockholm, Sweden</span><span style="font-size:9.0pt;color:#333333"><o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width="420" valign="top" style="width:315.0pt;padding:0cm 0cm 0cm 2.25pt">
<p class="MsoNormal" style="margin-top:2.0pt;line-height:9.0pt;mso-line-height-rule:exactly">
<span lang="EN-US" style="font-size:9.0pt;color:#333333;mso-fareast-language:SV"> Unit phone: +46 (0)8 797 70 20
<br>
</span><span style="font-size:9.0pt;color:#333333;mso-fareast-language:SV"><a href="http://www.lfv.se/"><span lang="EN-US">www.lfv.se</span></a></span><span lang="EN-US" style="font-size:9.0pt;color:#333333"><o:p></o:p></span></p>
</td>
</tr>
<tr style="height:3.7pt">
<td width="420" valign="top" style="width:315.0pt;padding:0cm 0cm 0cm 2.25pt;height:3.7pt">
<p class="MsoNormal" style="margin-top:6.0pt;line-height:9.0pt;mso-line-height-rule:exactly">
<span lang="EN-US" style="font-size:9.0pt;color:#00CC00;mso-fareast-language:SV"> Please consider the enviroment before printing this e-mail message.</span><span lang="EN-US" style="font-size:9.0pt;color:#00CC00"><o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span lang="EN-US" style="font-size:9.0pt;mso-fareast-language:SV"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</body>
</html>