Re: [postgis-users] ST_Split with Multilinestring

2016-06-16 Thread Birgit Laggner

Hi Sandro,

mmh... I really would like to, but I am no programmer and wouldn't know 
how to contribute and I am not in a position to decide about financing 
somebody to add this functionality. I'm sorry.


But thank you anyway for clarifying the current functionality status!

Regards,

Birgit

Am 16.06.2016 um 10:34 schrieb Sandro Santilli:

On Wed, Jun 15, 2016 at 07:19:34PM +0200, Birgit Laggner, vTI wrote:

Hi Sandro,

yes, I read so, too. But, our database has PostGIS version:
"POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel.
4.9.1, 04 March 2015" GDAL="GDAL 1.11.2, released 2015/02/10"
LIBXML="2.9.2" LIBJSON="0.11.99" TOPOLOGY RASTER" and I still get
that error. Any idea why?

Oops, sorry: 2.2.0 added capability to split _lines_ by multilines,
not _polygons_. Polygons are still only splittable by single linestrings.

It should be an easy addition, if you want to contribute or finance one.

--strk;



___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] ST_Split with Multilinestring

2016-06-16 Thread Birgit Laggner

Hi Rémi,

thank you for sharing your function. In the meantime I seem to have 
solved the problem by combining the st_split function with a function 
from an old use case:


CREATE OR REPLACE FUNCTION ST_SplitPolygon(poly geometry, blade 
geometry) RETURNS geometry AS

$$
declare
out_geom geometry;
begin
begin
out_geom := st_split(poly, blade);
exception when internal_error then
out_geom := ST_Collect((d).geom) FROM (SELECT 
ST_Dump(ST_Polygonize(ST_Union(ST_Boundary(poly), blade))) AS d) f WHERE 
ST_Area(ST_Intersection(poly, (d).geom)) / ST_Area((d).geom) >= 1 - 1e-10;

end;
return out_geom;
end;
$$
LANGUAGE plpgsql IMMUTABLE STRICT COST 100;

But I will definitely give your function a try and compare the results!

Thanks again! Regards,

Birgit

Am 16.06.2016 um 10:18 schrieb Rémi Cura:

Hey,
I wrote a multi-friendly st_split a while ago.
Maybe it will help you:
https://github.com/Remi-C/_utilities/blob/master/postgis/rc_split_multi.sql

Cheers,
Rémi-C

2016-06-15 19:19 GMT+02:00 Birgit Laggner, vTI 
>:


Hi Sandro,

yes, I read so, too. But, our database has PostGIS version:
"POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel.
4.9.1, 04 March 2015" GDAL="GDAL 1.11.2, released 2015/02/10"
LIBXML="2.9.2" LIBJSON="0.11.99" TOPOLOGY RASTER" and I still get
that error. Any idea why?

Regards,

Birgit


Am 15.06.2016 um 19:02 schrieb Sandro Santilli:

On Tue, Jun 14, 2016 at 02:52:52PM +0200, Birgit Laggner wrote:

ERROR: Splitting a Polygon by a MultiLineString is unsupported

Support for this functionality was added in PostGIS-2.2.0

--strk;



___
postgis-users mailing list
postgis-users@lists.osgeo.org 
http://lists.osgeo.org/mailman/listinfo/postgis-users




___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users


___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] ST_Split with Multilinestring

2016-06-16 Thread Sandro Santilli
On Wed, Jun 15, 2016 at 07:19:34PM +0200, Birgit Laggner, vTI wrote:
> Hi Sandro,
> 
> yes, I read so, too. But, our database has PostGIS version:
> "POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel.
> 4.9.1, 04 March 2015" GDAL="GDAL 1.11.2, released 2015/02/10"
> LIBXML="2.9.2" LIBJSON="0.11.99" TOPOLOGY RASTER" and I still get
> that error. Any idea why?

Oops, sorry: 2.2.0 added capability to split _lines_ by multilines,
not _polygons_. Polygons are still only splittable by single linestrings.

It should be an easy addition, if you want to contribute or finance one.

--strk;
___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] ST_Split with Multilinestring

2016-06-16 Thread Rémi Cura
Hey,
I wrote a multi-friendly st_split a while ago.
Maybe it will help you:
https://github.com/Remi-C/_utilities/blob/master/postgis/rc_split_multi.sql

Cheers,
Rémi-C

2016-06-15 19:19 GMT+02:00 Birgit Laggner, vTI :

> Hi Sandro,
>
> yes, I read so, too. But, our database has PostGIS version:
> "POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.9.1, 04
> March 2015" GDAL="GDAL 1.11.2, released 2015/02/10" LIBXML="2.9.2"
> LIBJSON="0.11.99" TOPOLOGY RASTER" and I still get that error. Any idea why?
>
> Regards,
>
> Birgit
>
>
> Am 15.06.2016 um 19:02 schrieb Sandro Santilli:
>
>> On Tue, Jun 14, 2016 at 02:52:52PM +0200, Birgit Laggner wrote:
>>
>> ERROR: Splitting a Polygon by a MultiLineString is unsupported
>>>
>> Support for this functionality was added in PostGIS-2.2.0
>>
>> --strk;
>>
>>
>
> ___
> postgis-users mailing list
> postgis-users@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/postgis-users
>
___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] ST_Split with Multilinestring

2016-06-15 Thread Birgit Laggner, vTI

Hi Sandro,

yes, I read so, too. But, our database has PostGIS version: 
"POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.9.1, 
04 March 2015" GDAL="GDAL 1.11.2, released 2015/02/10" LIBXML="2.9.2" 
LIBJSON="0.11.99" TOPOLOGY RASTER" and I still get that error. Any idea why?


Regards,

Birgit

Am 15.06.2016 um 19:02 schrieb Sandro Santilli:

On Tue, Jun 14, 2016 at 02:52:52PM +0200, Birgit Laggner wrote:


ERROR: Splitting a Polygon by a MultiLineString is unsupported

Support for this functionality was added in PostGIS-2.2.0

--strk;




___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] ST_Split with Multilinestring

2016-06-15 Thread Sandro Santilli
On Tue, Jun 14, 2016 at 02:52:52PM +0200, Birgit Laggner wrote:

> ERROR: Splitting a Polygon by a MultiLineString is unsupported

Support for this functionality was added in PostGIS-2.2.0

--strk;
___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] ST_Split with Multilinestring

2016-06-15 Thread Birgit Laggner
Yes, this function will probably work - that's similar to what I meant 
with "looping the ST_Split with some function, DO block or pgScript 
after selecting all intersecting linestrings per polygon" in my original 
mail. If my current approach fails, too, I will revert to some sort of 
looping approach like the one you suggested. Thanks again for taking the 
time to analyze my problem!


Regards,

Birgit


Achtung: Das Thünen-Institut hat die Domain gewechselt.
 Bitte ändern Sie meine Mailadresse in Ihrem Adressbuch!

Notice: Thünen Institute has changed its domain.
Please change my email address in your address book!


Dipl.-Geoökol. Birgit Laggner

Thünen-Institut für Ländliche Räume / Thünen Institute of Rural Studies
Bundesallee 50
38116 Braunschweig (Germany)

Tel: +49 531 596-5240
Mail: birgit.lagg...@thuenen.de
Web: www.thuenen.de

Am 15.06.2016 um 11:27 schrieb Marcin Mionskowski:
I think I finaly understand what you have and what you want to achieve 
- take a look at polygon and multiline definitions :)


If I'm right, this function should do the work:

create table polygon
(
id serial,
geom geometry,
done smallint default 0
);
create table multiline
(
id serial,
geom geometry,
done smallint default 0
);
create table line
(
id serial,
geom geometry,
done smallint default 0
);

insert into polygon (geom)
select ST_Buffer(ST_GeomFromText('POINT(10 10)'), 10);

insert into multiline (geom)
select ST_Union(
(select ST_MakeLine(ST_MakePoint(0, 1),ST_MakePoint(20, 21))),
(select ST_MakeLine(ST_MakePoint(1, 0),ST_MakePoint(20, 19)))
);

create or replace function test() returns void as
$BODY$

declare ln geometry;
i int;

BEGIN
truncate table line;

insert into line (geom)
select (ST_Dump(geom)).geom
from multiline;

loop
select geom,id
into ln,i
from line
where done=0
limit 1;

with
del as (
delete from polygon p
where ST_Intersects(p.geom,ln)
returning p.geom
)
insert into polygon (geom)
select (st_dump(st_split(del.geom,ln))).geom
from del;

update line
set done=1
where id=i;

exit when i is null;
end loop;
end;
$BODY$
LANGUAGE plpgsql;

select test();



On Wed, 15 Jun 2016 11:10:33 +0200, Birgit Laggner 
 wrote:



Dear list,

@Marcone: Unfortunately, the st_multi didn't change anything. The error
message is still the same.

Next, I will try some function from a user example from 2008
(https://trac.osgeo.org/postgis/wiki/UsersWikiSplitPolygonWithLineString). 


Maybe this will be a workaround.

But I am still wondering why I get the error message at all. I did find
a PostGIS ticket addressing the same functionality
(https://trac.osgeo.org/postgis/ticket/3097) and there is mentioned that
the problem is fixed with PostGIS 2.2.0. My PostGIS version is
"POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.9.1,
04 March 2015" GDAL="GDAL 1.11.2, released 2015/02/10" LIBXML="2.9.2"
LIBJSON="0.11.99" TOPOLOGY RASTER". So, I would suppose I shouldn't have
this problem.

Any other ideas?

Thanks and regards,

Birgit

Am 15.06.2016 um 10:01 schrieb Birgit Laggner:

Hi Marcin,

thanks for your reply. I don't think, that will provide the results I
am looking for. I am deliberately aggregating all intersecting lines
with ST_Union because otherwise the query would result in several
collections per polygon, each collection containig the st_split result
for one of the intersecting lines (blades). But I want the polygon cut
with all blades.

Currently I am trying Marcone's suggestion (although I cannot imagine
why this should solve anything - but you never know until you try,
right?).

So, thank you both, Marcin and Marcone!

Regards,

Birgit

Am 15.06.2016 um 09:24 schrieb Marcin Mionskowski:

On Tue, 14 Jun 2016 15:37:40 +0200, Marcone 
wrote:



2016-06-14 9:52 GMT-03:00 Birgit Laggner :

I would like to use the ST_Split function to split polygons from one
   table with all intersecting lines from another table.
Unfortunately,
   I get the following error:

 ERROR: Splitting a Polygon by a MultiLineString is unsupported

   SQL Status:XX000

 This is my query:

 select betr_id, (cut).path[1], (cut).geom from (select betr_id,
   st_dump(st_split) as cut from (select a.betr_id, ST_Split(a.geom,
   st_union(b.geom)) from p_sam.nihb_2013_convex_hull_betr a left 
join
   p_sam.ni_dlm13_aaa_gew_sie_ver_l b on st_intersects(a.geom, 
b.geom)

   group by a.betr_id, a.geom) sel1) sel2;

 The Manual contains the following info regarding this problem:

 "The function supports splitting a line by (multi)point,
(multi)line
   or (multi)polygon boundary, a (multi)polygon 

Re: [postgis-users] ST_Split with Multilinestring

2016-06-15 Thread Marcin Mionskowski

I think I finaly understand what you have and what you want to achieve - take a 
look at polygon and multiline definitions :)

If I'm right, this function should do the work:

create table polygon
(
id serial,
geom geometry,
done smallint default 0
);
create table multiline
(
id serial,
geom geometry,
done smallint default 0
);
create table line
(
id serial,
geom geometry,
done smallint default 0
);

insert into polygon (geom)
select ST_Buffer(ST_GeomFromText('POINT(10 10)'), 10);

insert into multiline (geom)
select ST_Union(
(select ST_MakeLine(ST_MakePoint(0, 1),ST_MakePoint(20, 21))),
(select ST_MakeLine(ST_MakePoint(1, 0),ST_MakePoint(20, 19)))
);

create or replace function test() returns void as
$BODY$

declare ln geometry;
i int;

BEGIN
truncate table line;

insert into line (geom)
select (ST_Dump(geom)).geom
from multiline;

loop
select geom,id
into ln,i
from line
where done=0
limit 1;

with
del as (
delete from polygon p
where ST_Intersects(p.geom,ln)
returning p.geom
)
insert into polygon (geom)
select (st_dump(st_split(del.geom,ln))).geom
from del;

update line
set done=1
where id=i;

exit when i is null;
end loop;
end;
$BODY$
LANGUAGE plpgsql;

select test();



On Wed, 15 Jun 2016 11:10:33 +0200, Birgit Laggner  
wrote:


Dear list,

@Marcone: Unfortunately, the st_multi didn't change anything. The error
message is still the same.

Next, I will try some function from a user example from 2008
(https://trac.osgeo.org/postgis/wiki/UsersWikiSplitPolygonWithLineString).
Maybe this will be a workaround.

But I am still wondering why I get the error message at all. I did find
a PostGIS ticket addressing the same functionality
(https://trac.osgeo.org/postgis/ticket/3097) and there is mentioned that
the problem is fixed with PostGIS 2.2.0. My PostGIS version is
"POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.9.1,
04 March 2015" GDAL="GDAL 1.11.2, released 2015/02/10" LIBXML="2.9.2"
LIBJSON="0.11.99" TOPOLOGY RASTER". So, I would suppose I shouldn't have
this problem.

Any other ideas?

Thanks and regards,

Birgit

Am 15.06.2016 um 10:01 schrieb Birgit Laggner:

Hi Marcin,

thanks for your reply. I don't think, that will provide the results I
am looking for. I am deliberately aggregating all intersecting lines
with ST_Union because otherwise the query would result in several
collections per polygon, each collection containig the st_split result
for one of the intersecting lines (blades). But I want the polygon cut
with all blades.

Currently I am trying Marcone's suggestion (although I cannot imagine
why this should solve anything - but you never know until you try,
right?).

So, thank you both, Marcin and Marcone!

Regards,

Birgit

Am 15.06.2016 um 09:24 schrieb Marcin Mionskowski:

On Tue, 14 Jun 2016 15:37:40 +0200, Marcone 
wrote:



2016-06-14 9:52 GMT-03:00 Birgit Laggner :

I would like to use the ST_Split function to split polygons from one
   table with all intersecting lines from another table.
Unfortunately,
   I get the following error:

 ERROR: Splitting a Polygon by a MultiLineString is unsupported

   SQL Status:XX000

 This is my query:

 select betr_id, (cut).path[1], (cut).geom from (select betr_id,
   st_dump(st_split) as cut from (select a.betr_id, ST_Split(a.geom,
   st_union(b.geom)) from p_sam.nihb_2013_convex_hull_betr a left join
   p_sam.ni_dlm13_aaa_gew_sie_ver_l b on st_intersects(a.geom, b.geom)
   group by a.betr_id, a.geom) sel1) sel2;

 The Manual contains the following info regarding this problem:

 "The function supports splitting a line by (multi)point,
(multi)line
   or (multi)polygon boundary, a (multi)polygon by line."

 This might mean that I would be able to split a line by
   multilinestrings, but a polygon only by single linestrings - is
that
   correct? Does anyone has a suggestion how I could work around this
   problem (aside from looping the ST_Split with some function, DO
   block or pgScript after selecting all intersecting linestrings per
   polygon)?

 Thanks a lot for any helpful suggestions!


I'm not sure if I understand your problem, but try use
ST_Split(st_multi(a.geom),
   st_union(b.geom)). I'm not test this, but I think that will solve
your problem.

Best regards.




Have you tried to ST_Dump multilinestrings first?
Using CTE this could look like:

with
a as ( --polygon
select ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50) a
),
b as ( --multilinestring
select ST_Union(
  

Re: [postgis-users] ST_Split with Multilinestring

2016-06-15 Thread Birgit Laggner

Dear list,

@Marcone: Unfortunately, the st_multi didn't change anything. The error 
message is still the same.


Next, I will try some function from a user example from 2008 
(https://trac.osgeo.org/postgis/wiki/UsersWikiSplitPolygonWithLineString). 
Maybe this will be a workaround.


But I am still wondering why I get the error message at all. I did find 
a PostGIS ticket addressing the same functionality 
(https://trac.osgeo.org/postgis/ticket/3097) and there is mentioned that 
the problem is fixed with PostGIS 2.2.0. My PostGIS version is 
"POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.9.1, 
04 March 2015" GDAL="GDAL 1.11.2, released 2015/02/10" LIBXML="2.9.2" 
LIBJSON="0.11.99" TOPOLOGY RASTER". So, I would suppose I shouldn't have 
this problem.


Any other ideas?

Thanks and regards,

Birgit

Am 15.06.2016 um 10:01 schrieb Birgit Laggner:

Hi Marcin,

thanks for your reply. I don't think, that will provide the results I 
am looking for. I am deliberately aggregating all intersecting lines 
with ST_Union because otherwise the query would result in several 
collections per polygon, each collection containig the st_split result 
for one of the intersecting lines (blades). But I want the polygon cut 
with all blades.


Currently I am trying Marcone's suggestion (although I cannot imagine 
why this should solve anything - but you never know until you try, 
right?).


So, thank you both, Marcin and Marcone!

Regards,

Birgit

Am 15.06.2016 um 09:24 schrieb Marcin Mionskowski:
On Tue, 14 Jun 2016 15:37:40 +0200, Marcone  
wrote:




2016-06-14 9:52 GMT-03:00 Birgit Laggner :

I would like to use the ST_Split function to split polygons from one
   table with all intersecting lines from another table. 
Unfortunately,

   I get the following error:

 ERROR: Splitting a Polygon by a MultiLineString is unsupported

   SQL Status:XX000

 This is my query:

 select betr_id, (cut).path[1], (cut).geom from (select betr_id,
   st_dump(st_split) as cut from (select a.betr_id, ST_Split(a.geom,
   st_union(b.geom)) from p_sam.nihb_2013_convex_hull_betr a left join
   p_sam.ni_dlm13_aaa_gew_sie_ver_l b on st_intersects(a.geom, b.geom)
   group by a.betr_id, a.geom) sel1) sel2;

 The Manual contains the following info regarding this problem:

 "The function supports splitting a line by (multi)point, 
(multi)line

   or (multi)polygon boundary, a (multi)polygon by line."

 This might mean that I would be able to split a line by
   multilinestrings, but a polygon only by single linestrings - is 
that

   correct? Does anyone has a suggestion how I could work around this
   problem (aside from looping the ST_Split with some function, DO
   block or pgScript after selecting all intersecting linestrings per
   polygon)?

 Thanks a lot for any helpful suggestions!


I'm not sure if I understand your problem, but try use 
ST_Split(st_multi(a.geom),
   st_union(b.geom)). I'm not test this, but I think that will solve 
your problem.


Best regards.




Have you tried to ST_Dump multilinestrings first?
Using CTE this could look like:

with
a as ( --polygon
select ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50) a
),
b as ( --multilinestring
select ST_Union(
(select ST_MakeLine(ST_MakePoint(10, 10),ST_MakePoint(190, 
190))),
(select ST_MakeLine(ST_MakePoint(191, 191),ST_MakePoint(200, 
200)))

) b
),
c as ( --multilinestring dump -> 2 separate linestrings
select (ST_Dump(b)).geom c
from b
)

SELECT ST_AsText(ST_Split(a, c))
from a,c
where ST_Intersects(a,c)

Intersection check is done here on line parts.

Regards
___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users


___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users


___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] ST_Split with Multilinestring

2016-06-15 Thread Birgit Laggner

Hi Marcin,

thanks for your reply. I don't think, that will provide the results I am 
looking for. I am deliberately aggregating all intersecting lines with 
ST_Union because otherwise the query would result in several collections 
per polygon, each collection containig the st_split result for one of 
the intersecting lines (blades). But I want the polygon cut with all blades.


Currently I am trying Marcone's suggestion (although I cannot imagine 
why this should solve anything - but you never know until you try, right?).


So, thank you both, Marcin and Marcone!

Regards,

Birgit

Am 15.06.2016 um 09:24 schrieb Marcin Mionskowski:
On Tue, 14 Jun 2016 15:37:40 +0200, Marcone  
wrote:




2016-06-14 9:52 GMT-03:00 Birgit Laggner :

I would like to use the ST_Split function to split polygons from one
   table with all intersecting lines from another table. Unfortunately,
   I get the following error:

 ERROR: Splitting a Polygon by a MultiLineString is unsupported

   SQL Status:XX000

 This is my query:

 select betr_id, (cut).path[1], (cut).geom from (select betr_id,
   st_dump(st_split) as cut from (select a.betr_id, ST_Split(a.geom,
   st_union(b.geom)) from p_sam.nihb_2013_convex_hull_betr a left join
   p_sam.ni_dlm13_aaa_gew_sie_ver_l b on st_intersects(a.geom, b.geom)
   group by a.betr_id, a.geom) sel1) sel2;

 The Manual contains the following info regarding this problem:

 "The function supports splitting a line by (multi)point, 
(multi)line

   or (multi)polygon boundary, a (multi)polygon by line."

 This might mean that I would be able to split a line by
   multilinestrings, but a polygon only by single linestrings - is that
   correct? Does anyone has a suggestion how I could work around this
   problem (aside from looping the ST_Split with some function, DO
   block or pgScript after selecting all intersecting linestrings per
   polygon)?

 Thanks a lot for any helpful suggestions!


I'm not sure if I understand your problem, but try use 
ST_Split(st_multi(a.geom),
   st_union(b.geom)). I'm not test this, but I think that will solve 
your problem.


Best regards.




Have you tried to ST_Dump multilinestrings first?
Using CTE this could look like:

with
a as ( --polygon
select ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50) a
),
b as ( --multilinestring
select ST_Union(
(select ST_MakeLine(ST_MakePoint(10, 10),ST_MakePoint(190, 
190))),
(select ST_MakeLine(ST_MakePoint(191, 191),ST_MakePoint(200, 
200)))

) b
),
c as ( --multilinestring dump -> 2 separate linestrings
select (ST_Dump(b)).geom c
from b
)

SELECT ST_AsText(ST_Split(a, c))
from a,c
where ST_Intersects(a,c)

Intersection check is done here on line parts.

Regards
___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users


___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] ST_Split with Multilinestring

2016-06-15 Thread Marcin Mionskowski

On Tue, 14 Jun 2016 15:37:40 +0200, Marcone  wrote:



2016-06-14 9:52 GMT-03:00 Birgit Laggner :

I would like to use the ST_Split function to split polygons from one
   table with all intersecting lines from another table. Unfortunately,
   I get the following error:

   
   ERROR: Splitting a Polygon by a MultiLineString is unsupported


   SQL Status:XX000

   
   This is my query:


   
   select betr_id, (cut).path[1], (cut).geom from (select betr_id,

   st_dump(st_split) as cut from (select a.betr_id, ST_Split(a.geom,
   st_union(b.geom)) from p_sam.nihb_2013_convex_hull_betr a left join
   p_sam.ni_dlm13_aaa_gew_sie_ver_l b on st_intersects(a.geom, b.geom)
   group by a.betr_id, a.geom) sel1) sel2;

   
   The Manual contains the following info regarding this problem:


   
   "The function supports splitting a line by (multi)point, (multi)line

   or (multi)polygon boundary, a (multi)polygon by line."

   
   This might mean that I would be able to split a line by

   multilinestrings, but a polygon only by single linestrings - is that
   correct? Does anyone has a suggestion how I could work around this
   problem (aside from looping the ST_Split with some function, DO
   block or pgScript after selecting all intersecting linestrings per
   polygon)?

   
   Thanks a lot for any helpful suggestions!


I'm not sure if I understand your problem, but try use 
ST_Split(st_multi(a.geom),
   st_union(b.geom)). I'm not test this, but I think that will solve your 
problem.

Best regards.




Have you tried to ST_Dump multilinestrings first?
Using CTE this could look like:

with
a as ( --polygon
select ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50) a
),
b as ( --multilinestring
select ST_Union(
(select ST_MakeLine(ST_MakePoint(10, 10),ST_MakePoint(190, 
190))),
(select ST_MakeLine(ST_MakePoint(191, 191),ST_MakePoint(200, 
200)))
) b
),
c as ( --multilinestring dump -> 2 separate linestrings
select (ST_Dump(b)).geom c
from b
)

SELECT ST_AsText(ST_Split(a, c))
from a,c
where ST_Intersects(a,c)

Intersection check is done here on line parts.

Regards
___
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/postgis-users