<div dir="ltr"><div><div>Also in your small code snippet you did't ensure that all your line where simple linestring (and not multilinestring).<br></div>Just to be sure : <br>SELECT COUNT(*) FROM ukrds WHERE ST_IsSimple(geom)=FALSE<br>
<br></div>Cheers,<br><br>Rémi<br><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/25 James David Smith <span dir="ltr"><<a href="mailto:james.david.smith@gmail.com" target="_blank">james.david.smith@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Steve,<br>
<br>
Thanks, you are of course right. I hadn't thought of that. Makes sense.<br>
<span class="HOEnZb"><font color="#888888"><br>
James<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 25 November 2013 17:58, Stephen Woodbridge <<a href="mailto:woodbri@swoodbridge.com">woodbri@swoodbridge.com</a>> wrote:<br>
> This is because lines shaped like say an Omega character, will create an<br>
> island inside the character at a certain offset and this can not be<br>
> represented as a simple polygon. Well maybe it can but the algorithm<br>
> probably does not try to reduce them to their most simple features. While<br>
> the lines may not intersect, the offset lines may intersect and it is a<br>
> function of how these are dealt with.<br>
><br>
> -Steve<br>
><br>
><br>
> On 11/25/2013 12:49 PM, James David Smith wrote:<br>
>><br>
>> Hi Remi/all,<br>
>><br>
>> I realise I'm digressing slightly from the point, but this seems<br>
>> related. This seems strange to me:<br>
>><br>
>> I check the geometry type of a table of what I think are linestrings<br>
>> (roads):<br>
>><br>
>> ukroads=# SELECT COUNT(*), geometrytype(geom) FROM ukrds GROUP BY<br>
>> geometrytype(geom);<br>
>> 395356 | LINESTRING<br>
>><br>
>> Great. They are all linestrings. Now I check that none of them are<br>
>> self-intersecting:<br>
>><br>
>> ukroads=# SELECT COUNT(*), st_issimple(geom) FROM ukrds GROUP BY<br>
>> st_issimple(geom);<br>
>>   395356 | t<br>
>><br>
>> Ok. That's fine. They are all ok.<br>
>><br>
>> Now I check that they are all valid:<br>
>><br>
>> ukroads=# SELECT COUNT(*), st_isvalid(geom) FROM ukrds GROUP BY<br>
>> st_isvalid(geom);<br>
>>   395356 | t<br>
>><br>
>> So now I buffer them all by 1000 metres wanting to make a polygon out<br>
>> of each line:<br>
>><br>
>> ukroads=# SELECT COUNT(a.*), geometrytype(a.the_geom) FROM (SELECT<br>
>> st_buffer(geom,1000) as the_geom FROM ukrds) AS a GROUP BY<br>
>> geometrytype(a.the_geom);<br>
>> 392255 | POLYGON<br>
>> 3101 | MULTIPOLYGON<br>
>><br>
>> However I am returned with 3101 multipolygons (and the rest polygons).<br>
>> Why is that? Should they not all be polygons? Why do some of them<br>
>> become a multipolygon?<br>
>><br>
>> Thanks<br>
>><br>
>> James<br>
>><br>
>> On 25 November 2013 17:25, Rémi Cura <<a href="mailto:remi.cura@gmail.com">remi.cura@gmail.com</a>> wrote:<br>
>>><br>
>>> You could use the default ending (which is well defined),<br>
>>> then split the resulting with the line like endcap=flat (easy to build,<br>
>>> translate endpoint by radius and -radius in normal direction)<br>
>>><br>
>>> I still fail to understand why you would need this kind of ending.<br>
>>><br>
>>> Cheers,<br>
>>><br>
>>> Rémi C<br>
>>><br>
>>><br>
>>> 2013/11/25 Rémi Cura <<a href="mailto:remi.cura@gmail.com">remi.cura@gmail.com</a>><br>
>>>><br>
>>>><br>
>>>> Does  offset curve gives the same result?<br>
>>>> (seems lile offsetting both side have same behavior)<br>
>>>><br>
>>>> Maybe you can try several buffers with increasing size?<br>
>>>> (default appears wau before 1000)<br>
>>>><br>
>>>> Also, can you try to simplify your line : each coordinates uses 15<br>
>>>> digits,<br>
>>>> surely you don't need all of this !<br>
>>>> (simplifying to 8 digits doesn't help).<br>
>>>><br>
>>>> It seems like a bad design in algorithm ?<br>
>>>><br>
>>>> Cheers,<br>
>>>> Rémi-C<br>
>>>><br>
>>>><br>
>>>> 2013/11/25 James David Smith <<a href="mailto:james.david.smith@gmail.com">james.david.smith@gmail.com</a>><br>
>>>>><br>
>>>>><br>
>>>>> Hi there,<br>
>>>>><br>
>>>>> Some code to illustrate my problem:<br>
>>>>><br>
>>>>> 1) A linestring (SRID: 27700)<br>
>>>>><br>
>>>>> LINESTRING(555936.152 200920.582000002,555938.312000002<br>
>>>>> 200908.102000002,555943.112000001 200883.142000001,555953.192000001<br>
>>>>> 200839.702,555964.471999999 200798.181999998,555974.312<br>
>>>>> 200764.342000002,555983.912 200744.182000002,555990.554<br>
>>>>> 200733.721000003,555993.512 200729.062000005,555995.778000002<br>
>>>>> 200726.756000001,556006.952000001 200715.382000001,556024.232<br>
>>>>> 200698.822000002,556036.597999999 200687.931,556050.392000001<br>
>>>>> 200675.782000002,556055.914 200671.265000002,556071.512<br>
>>>>> 200658.502000002,556094.915000001 200640.537000002,556095.451000001<br>
>>>>> 200640.152000001,556113.992000001 200628.742000001,556138.472000001<br>
>>>>> 200616.502000004,556159.112000002 200605.942000002,556180.232000001<br>
>>>>> 200589.862000002,556207.592 200568.022000002,556217.912000002<br>
>>>>> 200558.182,556228.472000001 200545.702,556240.472<br>
>>>>> 200527.702000003,556251.992000001 200509.221999999,556253.237000001<br>
>>>>> 200506.732000003,556258.952 200495.302000001,556268.000000001<br>
>>>>> 200478.000000002,556279.592 200458.582000002,556300<br>
>>>>> 200431.000000002,556351.000000002 200364,556349.253 200366.234000001)<br>
>>>>><br>
>>>>> 2) Now I buffer it:<br>
>>>>><br>
>>>>> SELECT ST_Buffer(<br>
>>>>>   ST_GeomFromText(<br>
>>>>>    'LINESTRING(555936.152 200920.582000002,555938.312000002<br>
>>>>> 200908.102000002,555943.112000001 200883.142000001,555953.192000001<br>
>>>>> 200839.702,555964.471999999 200798.181999998,555974.312<br>
>>>>> 200764.342000002,555983.912 200744.182000002,555990.554<br>
>>>>> 200733.721000003,555993.512 200729.062000005,555995.778000002<br>
>>>>> 200726.756000001,556006.952000001 200715.382000001,556024.232<br>
>>>>> 200698.822000002,556036.597999999 200687.931,556050.392000001<br>
>>>>> 200675.782000002,556055.914 200671.265000002,556071.512<br>
>>>>> 200658.502000002,556094.915000001 200640.537000002,556095.451000001<br>
>>>>> 200640.152000001,556113.992000001 200628.742000001,556138.472000001<br>
>>>>> 200616.502000004,556159.112000002 200605.942000002,556180.232000001<br>
>>>>> 200589.862000002,556207.592 200568.022000002,556217.912000002<br>
>>>>> 200558.182,556228.472000001 200545.702,556240.472<br>
>>>>> 200527.702000003,556251.992000001 200509.221999999,556253.237000001<br>
>>>>> 200506.732000003,556258.952 200495.302000001,556268.000000001<br>
>>>>> 200478.000000002,556279.592 200458.582000002,556300<br>
>>>>> 200431.000000002,556351.000000002 200364,556349.253<br>
>>>>> 200366.234000001)'), 1000, 'endcap=flat join=round');<br>
>>>>><br>
>>>>> 3) The result is attached as a jpg (line thickness increased to aid<br>
>>>>> viewing).<br>
>>>>><br>
>>>>> Any ideas please? This is related to an ongoing discussion I was<br>
>>>>> having with Remi a while ago. Basically I'm buffering loads of road<br>
>>>>> centrelines to create polygons. But when I do it, a small number end<br>
>>>>> up with really strange buffers like this attached example. I'm at a<br>
>>>>> loss as to why.<br>
>>>>><br>
>>>>> Thanks<br>
>>>>><br>
>>>>> James<br>
>>>>><br>
>>>>> _______________________________________________<br>
>>>>> postgis-users mailing list<br>
>>>>> <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
>>>>> <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
>>>><br>
>>>><br>
>>>><br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> postgis-users mailing list<br>
>>> <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
>>> <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
>><br>
>> _______________________________________________<br>
>> postgis-users mailing list<br>
>> <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
>> <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
>><br>
><br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br></div>