ST_Buffer returning multipolygons

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

ST_Buffer returning multipolygons

marquz74
Hi to all,
I'm practicing with ST_buffer on North Carolina Dataset (nc_spm_08).
By running the following query:

SELECT GeometryType(sub.buffer)
FROM (  
        SELECT st_buffer (the_geom, 100) AS buffer
        FROM streams
) AS sub  
WHERE
        GeometryType(sub.buffer)  <> 'POLYGON';

I've been getting some MULTIPOLYGON records.
Is it possible? I guessed ST_Buffer could return POLYGON geometries only... was I wrong?

Thanks in advance.

Marco
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

Hugues François
Hello,

If your input is a multipolygon, st_buffer may return a multipolygon
since your buffered the buffered polygons which compose your
multigeometry may not intersect each other.

Hugues.





-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of marquz74
Sent: Friday, January 18, 2013 12:41 AM
To: [hidden email]
Subject: [postgis-users] ST_Buffer returning multipolygons

Hi to all,
I'm practicing with ST_buffer on North Carolina Dataset (nc_spm_08).
By running the following query:

SELECT GeometryType(sub.buffer)
FROM (  
        SELECT st_buffer (the_geom, 100) AS buffer
        FROM streams
) AS sub
WHERE
        GeometryType(sub.buffer)  <> 'POLYGON';

I've been getting some MULTIPOLYGON records.
Is it possible? I guessed ST_Buffer could return POLYGON geometries
only...
was I wrong?

Thanks in advance.

Marco



--
View this message in context:
http://postgis.17.n6.nabble.com/ST-Buffer-returning-multipolygons-tp5002
333.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

Nicolas Ribot-2
Hi,

A precision: st_buffer can return a MP even on a regular polygon
See attached picture: internal buffer (negative distance) on the green Polygon:

select st_astext(
    st_buffer('POLYGON (( 118 270, 216 270, 172 211, 219 149, 96 150, 151 212, 118 270 ))'::geometry, -15)
);

Nicolas


On 18 January 2013 07:44, Francois Hugues <[hidden email]> wrote:
Hello,

If your input is a multipolygon, st_buffer may return a multipolygon
since your buffered the buffered polygons which compose your
multigeometry may not intersect each other.

Hugues.





-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of marquz74
Sent: Friday, January 18, 2013 12:41 AM
To: [hidden email]
Subject: [postgis-users] ST_Buffer returning multipolygons

Hi to all,
I'm practicing with ST_buffer on North Carolina Dataset (nc_spm_08).
By running the following query:

SELECT GeometryType(sub.buffer)
FROM (
        SELECT st_buffer (the_geom, 100) AS buffer
        FROM streams
) AS sub
WHERE
        GeometryType(sub.buffer)  <> 'POLYGON';

I've been getting some MULTIPOLYGON records.
Is it possible? I guessed ST_Buffer could return POLYGON geometries
only...
was I wrong?

Thanks in advance.

Marco



--
View this message in context:
<a href="http://postgis.17.n6.nabble.com/ST-Buffer-returning-multipolygons-tp5002 333.html" target="_blank">http://postgis.17.n6.nabble.com/ST-Buffer-returning-multipolygons-tp5002
333.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

marquz74
In reply to this post by Hugues François
Hi,
thank for your interest.
The input geometries are actually linestrings (streams layer), so I don't understand why I get MP.

Marco.
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

Hugues François
Hi,

We don't know what are your original geometries or what kind of buffer
you apply (since you work with linestrings we can assume it is a
positive buffer). Maybe some of your linestrings are multilinestrings
with disjoint components.

Did you try GeomeryType (geom) group by Geometry types ? What about
st_dump(geom) ?

You may have some more information here :
http://postgis.net/docs/manual-2.0/using_postgis_dbmanagement.html#OGC_V
alidity

Hugues.


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of marquz74
Sent: Friday, January 18, 2013 1:58 PM
To: [hidden email]
Subject: Re: [postgis-users] ST_Buffer returning multipolygons

Hi,
thank for your interest.
The input geometries are actually linestrings (streams layer), so I
don't understand why I get MP.

Marco.



--
View this message in context:
http://postgis.17.n6.nabble.com/ST-Buffer-returning-multipolygons-tp5002
333p5002337.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

Stephen V. Mather
I would agree with Hugues, you likely have multilinestrings.

Look to http://www.bostongis.com/postgis_dump.snippet for how to explode these into linestrings and then buffer.  Something like:

WITH singlelinestrings AS
     (
     SELECT stusps, ST_Multi(ST_Collect(f.the_geom)) as singlegeom FROM
      (SELECT stusps, (ST_Dump(the_geom)).geom As the_geom FROM somestatetable ) As f
       GROUP BY stusps
     )
SELECT ST_Buffer(singlegeom) FROM singlelinestrings

Best,
Steve

  Stephen V. Mather
GIS Manager
(216) 635-3243 (Work)
clevelandmetroparks.com


________________________________________
From: [hidden email] [[hidden email]] on behalf of Francois Hugues [[hidden email]]
Sent: Friday, January 18, 2013 8:39 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] ST_Buffer returning multipolygons

Hi,

We don't know what are your original geometries or what kind of buffer
you apply (since you work with linestrings we can assume it is a
positive buffer). Maybe some of your linestrings are multilinestrings
with disjoint components.

Did you try GeomeryType (geom) group by Geometry types ? What about
st_dump(geom) ?

You may have some more information here :
http://postgis.net/docs/manual-2.0/using_postgis_dbmanagement.html#OGC_V
alidity

Hugues.


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of marquz74
Sent: Friday, January 18, 2013 1:58 PM
To: [hidden email]
Subject: Re: [postgis-users] ST_Buffer returning multipolygons

Hi,
thank for your interest.
The input geometries are actually linestrings (streams layer), so I
don't understand why I get MP.

Marco.



--
View this message in context:
http://postgis.17.n6.nabble.com/ST-Buffer-returning-multipolygons-tp5002
333p5002337.html
Sent from the PostGIS - User mailing list archive at Nabble.com.
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

marquz74
In reply to this post by Hugues François
Francois Hugues wrote
We don't know what are your original geometries or what kind of buffer
you apply (since you work with linestrings we can assume it is a
positive buffer). Maybe some of your linestrings are multilinestrings
with disjoint components.
the query:

SELECT GeometryType(the_geom)
FROM streams
WHERE GeometryType(the_geom)  <> 'LINESTRING';

returns 0 records.

Regards,
Marco
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

Stephen Woodbridge
On 1/18/2013 11:10 AM, marquz74 wrote:

> Francois Hugues wrote
>> We don't know what are your original geometries or what kind of buffer
>> you apply (since you work with linestrings we can assume it is a
>> positive buffer). Maybe some of your linestrings are multilinestrings
>> with disjoint components.
>
> the query:
>
> SELECT GeometryType(the_geom)
> FROM streams
> WHERE GeometryType(the_geom)  <> 'LINESTRING';
>
> returns 0 records.

If you have a linestring that follows a stream or rivier then you likely
will have an ox bow like geometry, think of the letter Omega. If you add
enough buffer to this you will end up intersecting your buffer with
another part of the buffer. This creates polygon or multipolygon.

You could post you command and geometry so others can look at it.

select gid, astext(the_geom) from streams where
GeometryType(st_buffer(the_geom, <distance>)) = 'MULTIPOLYGON';

-Steve
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

marquz74
Stephen Woodbridge wrote
On 1/18/2013 11:10 AM, marquz74 wrote:
> Francois Hugues wrote
>> We don't know what are your original geometries or what kind of buffer
>> you apply (since you work with linestrings we can assume it is a
>> positive buffer). Maybe some of your linestrings are multilinestrings
>> with disjoint components.
>
> the query:
>
> SELECT GeometryType(the_geom)
> FROM streams
> WHERE GeometryType(the_geom)  <> 'LINESTRING';
>
> returns 0 records.

If you have a linestring that follows a stream or rivier then you likely
will have an ox bow like geometry, think of the letter Omega. If you add
enough buffer to this you will end up intersecting your buffer with
another part of the buffer. This creates polygon or multipolygon.

You could post you command and geometry so others can look at it.

select gid, astext(the_geom) from streams where
GeometryType(st_buffer(the_geom, <distance>)) = 'MULTIPOLYGON';
Ok. I have a totale of 8554 streams (LINESTRINGs).
With the query

SELECT gid, AsText(the_geom) FROM streams
WHERE GeometryType(st_buffer(the_geom, 100)) = 'MULTIPOLYGON';

I get 11 records as MULTIPOLYGONs

The first record is:

 674 | LINESTRING(640770.332537465 216785.425146015,640770.356311913 216785.560172686,640770.475488952 216786.226162019,640770.647396495 216787.800152365,640770.658978918 216789.268376902,640770.447752096 216792.399898366,640769.98018796 216795.624688816,640769.110287021 216798.527305023,640767.648768098 216801.891389348,640766.02448565 216804.805892778,640764.74005588 216807.134569434,640763.337363474 216809.560477487,640761.650901703 216812.246990061,640759.955600712 216815.327305019,640758.482499366 216817.868732504,640757.383693167 216819.548488661,640756.238862077 216821.226720821,640754.01503683 216824.434442434,640751.366929134 216828.435255234,640749.204368809 216832.450088865,640747.25516891 216836.227787618,640746.014020829 216838.801219168,640745.393751588 216840.360274284,640744.315976633 216842.854457673,640743.400050801 216844.65704848,640742.582575565 216846.277673322,640741.52491745 216848.478638524,640740.503835408 216850.705816576,640739.787553975 216852.270967708,640739.053289307 216853.851968469,640738.173025147 216855.546355058,640737.55488951 216856.568961104,640736.817272035 216857.822910812,640735.910795021 216859.35697228,640734.77510795 216861.236982439,640733.832969266 216862.938074642,640732.814325629 216865.039674844,640731.225095251 216869.012141189,640729.979984761 216871.879095724,640729.445974092 216873.02148841,640729.002794006 216873.679857725,640728.952197105 216873.745389857,640728.676962154 216874.089814544)

I isolated the stream and the related buffer, you can see large and small zoom at this links:
https://docs.google.com/file/d/0B0MkYF-Ljs34MlNkTkJwc0dEbG8/edit
https://docs.google.com/file/d/0B0MkYF-Ljs34c1owdkc1U0Q4OFk/edit

Thank you for your patience :-)

Marco
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

Stephen Woodbridge
Francois,

I can not see anything obviously wrong here. It is possible with large
offsets to generate loops in the offset curve that would show up as
slivers like you are getting.

1. file a bug report http://trac.osgeo.org/postgis/
    include you linesting and the command generating the problem
    include select postgis_full_version() output

2. "fix" these you can explode the multipolygon with st_dump and filter
out any little slivers using st_area() > tolerance

HTH,
   -Steve

On 1/18/2013 12:40 PM, marquz74 wrote:

> Stephen Woodbridge wrote
>> On 1/18/2013 11:10 AM, marquz74 wrote:
>>> Francois Hugues wrote
>>>> We don't know what are your original geometries or what kind of buffer
>>>> you apply (since you work with linestrings we can assume it is a
>>>> positive buffer). Maybe some of your linestrings are multilinestrings
>>>> with disjoint components.
>>>
>>> the query:
>>>
>>> SELECT GeometryType(the_geom)
>>> FROM streams
>>> WHERE GeometryType(the_geom)  <> 'LINESTRING';
>>>
>>> returns 0 records.
>>
>> If you have a linestring that follows a stream or rivier then you likely
>> will have an ox bow like geometry, think of the letter Omega. If you add
>> enough buffer to this you will end up intersecting your buffer with
>> another part of the buffer. This creates polygon or multipolygon.
>>
>> You could post you command and geometry so others can look at it.
>>
>> select gid, astext(the_geom) from streams where
>> GeometryType(st_buffer(the_geom,
>> <distance>
>> )) = 'MULTIPOLYGON';
>
> Ok. I have a totale of 8554 streams (LINESTRINGs).
> With the query
>
> SELECT gid, AsText(the_geom) FROM streams
> WHERE GeometryType(st_buffer(the_geom, 100)) = 'MULTIPOLYGON';
>
> I get 11 records as MULTIPOLYGONs
>
> The first record is:
>
>   674 | LINESTRING(640770.332537465 216785.425146015,640770.356311913
> 216785.560172686,640770.475488952 216786.226162019,640770.647396495
> 216787.800152365,640770.658978918 216789.268376902,640770.447752096
> 216792.399898366,640769.98018796 216795.624688816,640769.110287021
> 216798.527305023,640767.648768098 216801.891389348,640766.02448565
> 216804.805892778,640764.74005588 216807.134569434,640763.337363474
> 216809.560477487,640761.650901703 216812.246990061,640759.955600712
> 216815.327305019,640758.482499366 216817.868732504,640757.383693167
> 216819.548488661,640756.238862077 216821.226720821,640754.01503683
> 216824.434442434,640751.366929134 216828.435255234,640749.204368809
> 216832.450088865,640747.25516891 216836.227787618,640746.014020829
> 216838.801219168,640745.393751588 216840.360274284,640744.315976633
> 216842.854457673,640743.400050801 216844.65704848,640742.582575565
> 216846.277673322,640741.52491745 216848.478638524,640740.503835408
> 216850.705816576,640739.787553975 216852.270967708,640739.053289307
> 216853.851968469,640738.173025147 216855.546355058,640737.55488951
> 216856.568961104,640736.817272035 216857.822910812,640735.910795021
> 216859.35697228,640734.77510795 216861.236982439,640733.832969266
> 216862.938074642,640732.814325629 216865.039674844,640731.225095251
> 216869.012141189,640729.979984761 216871.879095724,640729.445974092
> 216873.02148841,640729.002794006 216873.679857725,640728.952197105
> 216873.745389857,640728.676962154 216874.089814544)
>
> I isolated the stream and the related buffer, you can see large and small
> zoom at this links:
> https://docs.google.com/file/d/0B0MkYF-Ljs34MlNkTkJwc0dEbG8/edit
> https://docs.google.com/file/d/0B0MkYF-Ljs34c1owdkc1U0Q4OFk/edit
>
> Thank you for your patience :-)
>
> Marco
>
>
>
> --
> View this message in context: http://postgis.17.n6.nabble.com/ST-Buffer-returning-multipolygons-tp5002333p5002345.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> _______________________________________________
> postgis-users mailing list
> [hidden email]
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

Hugues François
This time, I'm not the one who have a problem ! (and you can call me Hugues ;))

This artifact is very strange and I reproduced it at home with exactly the same result.

Hugues.


 

-----Message d'origine-----
De : [hidden email] [mailto:[hidden email]] De la part de Stephen Woodbridge
Envoyé : vendredi 18 janvier 2013 19:45
À : [hidden email]
Objet : Re: [postgis-users] ST_Buffer returning multipolygons

Francois,

I can not see anything obviously wrong here. It is possible with large offsets to generate loops in the offset curve that would show up as slivers like you are getting.

1. file a bug report http://trac.osgeo.org/postgis/
    include you linesting and the command generating the problem
    include select postgis_full_version() output

2. "fix" these you can explode the multipolygon with st_dump and filter out any little slivers using st_area() > tolerance

HTH,
   -Steve

On 1/18/2013 12:40 PM, marquz74 wrote:

> Stephen Woodbridge wrote
>> On 1/18/2013 11:10 AM, marquz74 wrote:
>>> Francois Hugues wrote
>>>> We don't know what are your original geometries or what kind of
>>>> buffer you apply (since you work with linestrings we can assume it
>>>> is a positive buffer). Maybe some of your linestrings are
>>>> multilinestrings with disjoint components.
>>>
>>> the query:
>>>
>>> SELECT GeometryType(the_geom)
>>> FROM streams
>>> WHERE GeometryType(the_geom)  <> 'LINESTRING';
>>>
>>> returns 0 records.
>>
>> If you have a linestring that follows a stream or rivier then you
>> likely will have an ox bow like geometry, think of the letter Omega.
>> If you add enough buffer to this you will end up intersecting your
>> buffer with another part of the buffer. This creates polygon or multipolygon.
>>
>> You could post you command and geometry so others can look at it.
>>
>> select gid, astext(the_geom) from streams where
>> GeometryType(st_buffer(the_geom, <distance>
>> )) = 'MULTIPOLYGON';
>
> Ok. I have a totale of 8554 streams (LINESTRINGs).
> With the query
>
> SELECT gid, AsText(the_geom) FROM streams WHERE
> GeometryType(st_buffer(the_geom, 100)) = 'MULTIPOLYGON';
>
> I get 11 records as MULTIPOLYGONs
>
> The first record is:
>
>   674 | LINESTRING(640770.332537465 216785.425146015,640770.356311913
> 216785.560172686,640770.475488952 216786.226162019,640770.647396495
> 216787.800152365,640770.658978918 216789.268376902,640770.447752096
> 216792.399898366,640769.98018796 216795.624688816,640769.110287021
> 216798.527305023,640767.648768098 216801.891389348,640766.02448565
> 216804.805892778,640764.74005588 216807.134569434,640763.337363474
> 216809.560477487,640761.650901703 216812.246990061,640759.955600712
> 216815.327305019,640758.482499366 216817.868732504,640757.383693167
> 216819.548488661,640756.238862077 216821.226720821,640754.01503683
> 216824.434442434,640751.366929134 216828.435255234,640749.204368809
> 216832.450088865,640747.25516891 216836.227787618,640746.014020829
> 216838.801219168,640745.393751588 216840.360274284,640744.315976633
> 216842.854457673,640743.400050801 216844.65704848,640742.582575565
> 216846.277673322,640741.52491745 216848.478638524,640740.503835408
> 216850.705816576,640739.787553975 216852.270967708,640739.053289307
> 216853.851968469,640738.173025147 216855.546355058,640737.55488951
> 216856.568961104,640736.817272035 216857.822910812,640735.910795021
> 216859.35697228,640734.77510795 216861.236982439,640733.832969266
> 216862.938074642,640732.814325629 216865.039674844,640731.225095251
> 216869.012141189,640729.979984761 216871.879095724,640729.445974092
> 216873.02148841,640729.002794006 216873.679857725,640728.952197105
> 216873.745389857,640728.676962154 216874.089814544)
>
> I isolated the stream and the related buffer, you can see large and
> small zoom at this links:
> https://docs.google.com/file/d/0B0MkYF-Ljs34MlNkTkJwc0dEbG8/edit
> https://docs.google.com/file/d/0B0MkYF-Ljs34c1owdkc1U0Q4OFk/edit
>
> Thank you for your patience :-)
>
> Marco
>
>
>
> --
> View this message in context:
> http://postgis.17.n6.nabble.com/ST-Buffer-returning-multipolygons-tp50
> 02333p5002345.html Sent from the PostGIS - User mailing list archive
> at Nabble.com.
> _______________________________________________
> postgis-users mailing list
> [hidden email]
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

marquz74
In reply to this post by Stephen Woodbridge
Steve your suggestion solves the problem, very grateful to you!
I'll point out the bug as you recommend.
And thanks to all for the time you spent.
Marco


Stephen Woodbridge wrote
Francois,

I can not see anything obviously wrong here. It is possible with large
offsets to generate loops in the offset curve that would show up as
slivers like you are getting.

1. file a bug report http://trac.osgeo.org/postgis/
    include you linesting and the command generating the problem
    include select postgis_full_version() output

2. "fix" these you can explode the multipolygon with st_dump and filter
out any little slivers using st_area() > tolerance

HTH,
   -Steve

On 1/18/2013 12:40 PM, marquz74 wrote:
> Stephen Woodbridge wrote
>> On 1/18/2013 11:10 AM, marquz74 wrote:
>>> Francois Hugues wrote
>>>> We don't know what are your original geometries or what kind of buffer
>>>> you apply (since you work with linestrings we can assume it is a
>>>> positive buffer). Maybe some of your linestrings are multilinestrings
>>>> with disjoint components.
>>>
>>> the query:
>>>
>>> SELECT GeometryType(the_geom)
>>> FROM streams
>>> WHERE GeometryType(the_geom)  <> 'LINESTRING';
>>>
>>> returns 0 records.
>>
>> If you have a linestring that follows a stream or rivier then you likely
>> will have an ox bow like geometry, think of the letter Omega. If you add
>> enough buffer to this you will end up intersecting your buffer with
>> another part of the buffer. This creates polygon or multipolygon.
>>
>> You could post you command and geometry so others can look at it.
>>
>> select gid, astext(the_geom) from streams where
>> GeometryType(st_buffer(the_geom,
>> <distance>
>> )) = 'MULTIPOLYGON';
>
> Ok. I have a totale of 8554 streams (LINESTRINGs).
> With the query
>
> SELECT gid, AsText(the_geom) FROM streams
> WHERE GeometryType(st_buffer(the_geom, 100)) = 'MULTIPOLYGON';
>
> I get 11 records as MULTIPOLYGONs
>
> The first record is:
>
>   674 | LINESTRING(640770.332537465 216785.425146015,640770.356311913
> 216785.560172686,640770.475488952 216786.226162019,640770.647396495
> 216787.800152365,640770.658978918 216789.268376902,640770.447752096
> 216792.399898366,640769.98018796 216795.624688816,640769.110287021
> 216798.527305023,640767.648768098 216801.891389348,640766.02448565
> 216804.805892778,640764.74005588 216807.134569434,640763.337363474
> 216809.560477487,640761.650901703 216812.246990061,640759.955600712
> 216815.327305019,640758.482499366 216817.868732504,640757.383693167
> 216819.548488661,640756.238862077 216821.226720821,640754.01503683
> 216824.434442434,640751.366929134 216828.435255234,640749.204368809
> 216832.450088865,640747.25516891 216836.227787618,640746.014020829
> 216838.801219168,640745.393751588 216840.360274284,640744.315976633
> 216842.854457673,640743.400050801 216844.65704848,640742.582575565
> 216846.277673322,640741.52491745 216848.478638524,640740.503835408
> 216850.705816576,640739.787553975 216852.270967708,640739.053289307
> 216853.851968469,640738.173025147 216855.546355058,640737.55488951
> 216856.568961104,640736.817272035 216857.822910812,640735.910795021
> 216859.35697228,640734.77510795 216861.236982439,640733.832969266
> 216862.938074642,640732.814325629 216865.039674844,640731.225095251
> 216869.012141189,640729.979984761 216871.879095724,640729.445974092
> 216873.02148841,640729.002794006 216873.679857725,640728.952197105
> 216873.745389857,640728.676962154 216874.089814544)
>
> I isolated the stream and the related buffer, you can see large and small
> zoom at this links:
> https://docs.google.com/file/d/0B0MkYF-Ljs34MlNkTkJwc0dEbG8/edit
> https://docs.google.com/file/d/0B0MkYF-Ljs34c1owdkc1U0Q4OFk/edit
>
> Thank you for your patience :-)
>
> Marco
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

Stephen Woodbridge
In reply to this post by Hugues François
Hugues,

Sorry for the mix up and thank you for your confirmation of this
problem. Marco said he will write up a bug for this.

-Steve

On 1/18/2013 3:02 PM, Francois Hugues wrote:

> This time, I'm not the one who have a problem ! (and you can call me Hugues ;))
>
> This artifact is very strange and I reproduced it at home with exactly the same result.
>
> Hugues.
>
>
>
>
> -----Message d'origine-----
> De : [hidden email] [mailto:[hidden email]] De la part de Stephen Woodbridge
> Envoyé : vendredi 18 janvier 2013 19:45
> À : [hidden email]
> Objet : Re: [postgis-users] ST_Buffer returning multipolygons
>
> Francois,
>
> I can not see anything obviously wrong here. It is possible with large offsets to generate loops in the offset curve that would show up as slivers like you are getting.
>
> 1. file a bug report http://trac.osgeo.org/postgis/
>      include you linesting and the command generating the problem
>      include select postgis_full_version() output
>
> 2. "fix" these you can explode the multipolygon with st_dump and filter out any little slivers using st_area() > tolerance
>
> HTH,
>     -Steve
>
> On 1/18/2013 12:40 PM, marquz74 wrote:
>> Stephen Woodbridge wrote
>>> On 1/18/2013 11:10 AM, marquz74 wrote:
>>>> Francois Hugues wrote
>>>>> We don't know what are your original geometries or what kind of
>>>>> buffer you apply (since you work with linestrings we can assume it
>>>>> is a positive buffer). Maybe some of your linestrings are
>>>>> multilinestrings with disjoint components.
>>>>
>>>> the query:
>>>>
>>>> SELECT GeometryType(the_geom)
>>>> FROM streams
>>>> WHERE GeometryType(the_geom)  <> 'LINESTRING';
>>>>
>>>> returns 0 records.
>>>
>>> If you have a linestring that follows a stream or rivier then you
>>> likely will have an ox bow like geometry, think of the letter Omega.
>>> If you add enough buffer to this you will end up intersecting your
>>> buffer with another part of the buffer. This creates polygon or multipolygon.
>>>
>>> You could post you command and geometry so others can look at it.
>>>
>>> select gid, astext(the_geom) from streams where
>>> GeometryType(st_buffer(the_geom, <distance>
>>> )) = 'MULTIPOLYGON';
>>
>> Ok. I have a totale of 8554 streams (LINESTRINGs).
>> With the query
>>
>> SELECT gid, AsText(the_geom) FROM streams WHERE
>> GeometryType(st_buffer(the_geom, 100)) = 'MULTIPOLYGON';
>>
>> I get 11 records as MULTIPOLYGONs
>>
>> The first record is:
>>
>>    674 | LINESTRING(640770.332537465 216785.425146015,640770.356311913
>> 216785.560172686,640770.475488952 216786.226162019,640770.647396495
>> 216787.800152365,640770.658978918 216789.268376902,640770.447752096
>> 216792.399898366,640769.98018796 216795.624688816,640769.110287021
>> 216798.527305023,640767.648768098 216801.891389348,640766.02448565
>> 216804.805892778,640764.74005588 216807.134569434,640763.337363474
>> 216809.560477487,640761.650901703 216812.246990061,640759.955600712
>> 216815.327305019,640758.482499366 216817.868732504,640757.383693167
>> 216819.548488661,640756.238862077 216821.226720821,640754.01503683
>> 216824.434442434,640751.366929134 216828.435255234,640749.204368809
>> 216832.450088865,640747.25516891 216836.227787618,640746.014020829
>> 216838.801219168,640745.393751588 216840.360274284,640744.315976633
>> 216842.854457673,640743.400050801 216844.65704848,640742.582575565
>> 216846.277673322,640741.52491745 216848.478638524,640740.503835408
>> 216850.705816576,640739.787553975 216852.270967708,640739.053289307
>> 216853.851968469,640738.173025147 216855.546355058,640737.55488951
>> 216856.568961104,640736.817272035 216857.822910812,640735.910795021
>> 216859.35697228,640734.77510795 216861.236982439,640733.832969266
>> 216862.938074642,640732.814325629 216865.039674844,640731.225095251
>> 216869.012141189,640729.979984761 216871.879095724,640729.445974092
>> 216873.02148841,640729.002794006 216873.679857725,640728.952197105
>> 216873.745389857,640728.676962154 216874.089814544)
>>
>> I isolated the stream and the related buffer, you can see large and
>> small zoom at this links:
>> https://docs.google.com/file/d/0B0MkYF-Ljs34MlNkTkJwc0dEbG8/edit
>> https://docs.google.com/file/d/0B0MkYF-Ljs34c1owdkc1U0Q4OFk/edit
>>
>> Thank you for your patience :-)
>>
>> Marco
>>
>>
>>
>> --
>> View this message in context:
>> http://postgis.17.n6.nabble.com/ST-Buffer-returning-multipolygons-tp50
>> 02333p5002345.html Sent from the PostGIS - User mailing list archive
>> at Nabble.com.
>> _______________________________________________
>> postgis-users mailing list
>> [hidden email]
>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>>
>
> _______________________________________________
> postgis-users mailing list
> [hidden email]
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> [hidden email]
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|

Re: ST_Buffer returning multipolygons

Martin Davis-6
In reply to this post by marquz74
Buffers of single LineStrings should NEVER produce a polygon with more
than one component.  So this issue was puzzling - until the test data
and images were posted.  They reveal that the problem is a robustness
error deep inside the JTS/GEOS buffer code (the problem shows up
identically in JTS as well).

A quick fix is to add a post-computation filter which keeps only the
largest polygon component in situations where single polygons are
expected (i.e. buffers of points, single linestrings, and positive
buffers of single polygons).  This can be done externally - and ideally
it should be built into the JTS/GEOS buffer code (as a temporary hack,
against the day when the basic algorithm can be improved to eliminate
the problem).

(Cross-posting to GEOS list as well).

On 1/18/2013 9:40 AM, marquz74 wrote:

> Stephen Woodbridge wrote
>> On 1/18/2013 11:10 AM, marquz74 wrote:
>>> Francois Hugues wrote
>>>> We don't know what are your original geometries or what kind of buffer
>>>> you apply (since you work with linestrings we can assume it is a
>>>> positive buffer). Maybe some of your linestrings are multilinestrings
>>>> with disjoint components.
>>> the query:
>>>
>>> SELECT GeometryType(the_geom)
>>> FROM streams
>>> WHERE GeometryType(the_geom)  <> 'LINESTRING';
>>>
>>> returns 0 records.
>> If you have a linestring that follows a stream or rivier then you likely
>> will have an ox bow like geometry, think of the letter Omega. If you add
>> enough buffer to this you will end up intersecting your buffer with
>> another part of the buffer. This creates polygon or multipolygon.
>>
>> You could post you command and geometry so others can look at it.
>>
>> select gid, astext(the_geom) from streams where
>> GeometryType(st_buffer(the_geom,
>> <distance>
>> )) = 'MULTIPOLYGON';
> Ok. I have a totale of 8554 streams (LINESTRINGs).
> With the query
>
> SELECT gid, AsText(the_geom) FROM streams
> WHERE GeometryType(st_buffer(the_geom, 100)) = 'MULTIPOLYGON';
>
> I get 11 records as MULTIPOLYGONs
>
> The first record is:
>
>   674 | LINESTRING(640770.332537465 216785.425146015,640770.356311913
> 216785.560172686,640770.475488952 216786.226162019,640770.647396495
> 216787.800152365,640770.658978918 216789.268376902,640770.447752096
> 216792.399898366,640769.98018796 216795.624688816,640769.110287021
> 216798.527305023,640767.648768098 216801.891389348,640766.02448565
> 216804.805892778,640764.74005588 216807.134569434,640763.337363474
> 216809.560477487,640761.650901703 216812.246990061,640759.955600712
> 216815.327305019,640758.482499366 216817.868732504,640757.383693167
> 216819.548488661,640756.238862077 216821.226720821,640754.01503683
> 216824.434442434,640751.366929134 216828.435255234,640749.204368809
> 216832.450088865,640747.25516891 216836.227787618,640746.014020829
> 216838.801219168,640745.393751588 216840.360274284,640744.315976633
> 216842.854457673,640743.400050801 216844.65704848,640742.582575565
> 216846.277673322,640741.52491745 216848.478638524,640740.503835408
> 216850.705816576,640739.787553975 216852.270967708,640739.053289307
> 216853.851968469,640738.173025147 216855.546355058,640737.55488951
> 216856.568961104,640736.817272035 216857.822910812,640735.910795021
> 216859.35697228,640734.77510795 216861.236982439,640733.832969266
> 216862.938074642,640732.814325629 216865.039674844,640731.225095251
> 216869.012141189,640729.979984761 216871.879095724,640729.445974092
> 216873.02148841,640729.002794006 216873.679857725,640728.952197105
> 216873.745389857,640728.676962154 216874.089814544)
>
> I isolated the stream and the related buffer, you can see large and small
> zoom at this links:
> https://docs.google.com/file/d/0B0MkYF-Ljs34MlNkTkJwc0dEbG8/edit
> https://docs.google.com/file/d/0B0MkYF-Ljs34c1owdkc1U0Q4OFk/edit
>
> Thank you for your patience :-)
>
> Marco
>
>
>
> --
> View this message in context: http://postgis.17.n6.nabble.com/ST-Buffer-returning-multipolygons-tp5002333p5002345.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> _______________________________________________
> postgis-users mailing list
> [hidden email]
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>

_______________________________________________
postgis-users mailing list
[hidden email]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users