[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] Custom st_simplify function
From:       Phil Bartie <philbartie () gmail ! com>
Date:       2020-02-15 20:02:20
Message-ID: CA+z0MvpAy_zWZ8iWKSzgu9kXZtmwT5Zuv1DaoVBGN=QQiKwAPw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


How about the example here?
Z and M should be supported.

https://postgis.net/docs/manual-1.5/ST_Line_Substring.html


--The below example simulates a while loop in
--SQL using PostgreSQL generate_series() to cut all
--linestrings in a table to 100 unit segments
-- of which no segment is longer than 100 units
-- units are measured in the SRID units of measurement
-- It also assumes all geometries are LINESTRING or contiguous MULTILINESTRING
--and no geometry is longer than 100 units*10000
--for better performance you can reduce the 10000
--to match max number of segments you expect

SELECT field1, field2, ST_Line_Substring(the_geom, 100.00*n/length,
  CASE
	WHEN 100.00*(n+1) < length THEN 100.00*(n+1)/length
	ELSE 1
  END) As the_geom
FROM
  (SELECT sometable.field1, sometable.field2,
  ST_LineMerge(sometable.the_geom) AS the_geom,
  ST_Length(sometable.the_geom) As length
  FROM sometable
  ) AS t
CROSS JOIN generate_series(0,10000) AS n
WHERE n*100.00/length < 1;
			





On Sat, 15 Feb 2020 at 19:25, Alexander Gataric <gataric@usa.net> wrote:

> I tried to use st_segmentize but found that the m coordinate gets
> corrupted.
>
> Get BlueMail for Android <http://www.bluemail.me/r?b=15774>
> On Feb 15, 2020, at 12:50 PM, Phil Bartie <philbartie@gmail.com> wrote:
>>
>> Would ST_Segmentize() do what you are after?
>>  Run it after the simplify.
>>
>> https://postgis.net/docs/ST_Segmentize
>>
>> Might need to use in conjunction with ST_Union()
>>
>>
>>
>>
>>
>> On Sat, 15 Feb 2020 at 18:44, Alexander Gataric <gataric@usa.net> wrote:
>>
>>> I mean if a line is one mile long and is simplified into five 1000 foot
>>> segments, I want the longest segment to be 500 feet instead of 1000 feet.
>>>
>>> Get BlueMail for Android <http://www.bluemail.me/r?b=15774>
>>> On Feb 15, 2020, at 11:47 AM, Martin Davis <mtnclimb@gmail.com> wrote:
>>>>
>>>> You mean you want to keep simplifying until there are no segments of
>>>> length greater than the maximum?  (Presumably excluding input segments
>>>> already longer?)
>>>>
>>>> On Fri, Feb 14, 2020, 1:57 PM Alexander Gataric <gataric@usa.net>
>>>> wrote:
>>>>
>>>>> Is there a way to modify st_simplify to have a maximum segment length?
>>>>> I want to be able to limit it to 500 feet.
>>>>>
>>>>> Get BlueMail for Android <http://www.bluemail.me/r?b=15774>
>>>>>
>>>>> _______________________________________________
>>>>> postgis-users mailing list
>>>>> postgis-users@lists.osgeo.org
>>>>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>>>
>>>> ------------------------------
>>>>
>>>> postgis-users mailing list
>>>> postgis-users@lists.osgeo.org
>>>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>>>
>>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users@lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>
>> ------------------------------
>>
>> postgis-users mailing list
>> postgis-users@lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>
>> _______________________________________________
> postgis-users mailing list
> postgis-users@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users

[Attachment #5 (text/html)]

<div><div dir="auto">How about the example here?</div></div><div dir="auto">Z and M \
should be supported.</div><div dir="auto"><br></div><div dir="auto"><div><a \
href="https://postgis.net/docs/manual-1.5/ST_Line_Substring.html">https://postgis.net/docs/manual-1.5/ST_Line_Substring.html</a></div></div><div \
dir="auto"><br></div><div dir="auto"><pre class="programlisting" \
style="border-width:2px 0px;font-family:&quot;Courier \
New&quot;,Courier,Monaco,monospace;line-height:16px;border-color:rgb(247,147,30);borde \
r-style:solid;font-size:11px;margin-bottom:10px;margin-top:10px;overflow:auto;padding: \
10px;background-color:rgb(248,248,249);border-top-left-radius:2px;border-top-right-rad \
ius:2px;border-bottom-right-radius:2px;border-bottom-left-radius:2px;color:rgb(46,46,46)">
                
--The below example simulates a while loop in
--SQL using PostgreSQL generate_series() to cut all
--linestrings in a table to 100 unit segments
-- of which no segment is longer than 100 units
-- units are measured in the SRID units of measurement
-- It also assumes all geometries are LINESTRING or contiguous MULTILINESTRING
--and no geometry is longer than 100 units*10000
--for better performance you can reduce the 10000
--to match max number of segments you expect

SELECT field1, field2, ST_Line_Substring(the_geom, 100.00*n/length,
  CASE
	WHEN 100.00*(n+1) &lt; length THEN 100.00*(n+1)/length
	ELSE 1
  END) As the_geom
FROM
  (SELECT sometable.field1, sometable.field2,
  ST_LineMerge(sometable.the_geom) AS the_geom,
  ST_Length(sometable.the_geom) As length
  FROM sometable
  ) AS t
CROSS JOIN generate_series(0,10000) AS n
WHERE n*100.00/length &lt; 1;
			</pre><pre class="programlisting" style="border-width:2px \
0px;font-family:&quot;Courier \
New&quot;,Courier,Monaco,monospace;line-height:16px;border-color:rgb(247,147,30);borde \
r-style:solid;font-size:11px;margin-bottom:10px;margin-top:10px;overflow:auto;padding: \
10px;background-color:rgb(248,248,249);border-top-left-radius:2px;border-top-right-rad \
ius:2px;border-bottom-right-radius:2px;border-bottom-left-radius:2px;color:rgb(46,46,46)"><br></pre><pre \
class="programlisting" style="border-width:2px 0px;font-family:&quot;Courier \
New&quot;,Courier,Monaco,monospace;line-height:16px;border-color:rgb(247,147,30);borde \
r-style:solid;font-size:11px;margin-bottom:10px;margin-top:10px;overflow:auto;padding: \
10px;background-color:rgb(248,248,249);border-top-left-radius:2px;border-top-right-rad \
ius:2px;border-bottom-right-radius:2px;border-bottom-left-radius:2px;color:rgb(46,46,46)"><br></pre></div><div \
dir="auto"><br></div><div><br><div class="gmail_quote"><div dir="ltr" \
class="gmail_attr">On Sat, 15 Feb 2020 at 19:25, Alexander Gataric &lt;<a \
href="mailto:gataric@usa.net">gataric@usa.net</a>&gt; wrote:<br></div><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div style="zoom:0%"><div dir="auto">I tried to use \
st_segmentize but found that the m coordinate gets corrupted.<br><br></div> <div \
dir="auto">Get <a href="http://www.bluemail.me/r?b=15774" target="_blank">BlueMail \
for Android</a> </div></div><div style="zoom:0%"> <div class="gmail_quote">On Feb 15, \
2020, at 12:50 PM, Phil Bartie &lt;<a href="mailto:philbartie@gmail.com" \
target="_blank">philbartie@gmail.com</a>&gt; wrote:<blockquote class="gmail_quote" \
style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"> <div><div dir="auto">Would ST_Segmentize() do \
what you are after?</div><div dir="auto">  Run it after the simplify.  \
</div></div><div dir="auto"><br></div><div dir="auto"><div><a \
href="https://postgis.net/docs/ST_Segmentize" \
target="_blank">https://postgis.net/docs/ST_Segmentize</a></div></div><div \
dir="auto"><br></div><div dir="auto">Might need to use in conjunction with \
ST_Union()</div><div dir="auto"><br></div><div dir="auto"><br></div><div \
dir="auto"><br></div><div dir="auto"><br></div><div><br><div class="gmail_quote"><div \
dir="ltr" class="gmail_attr">On Sat, 15 Feb 2020 at 18:44, Alexander Gataric &lt;<a \
href="mailto:gataric@usa.net" target="_blank">gataric@usa.net</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="zoom:0%"><div \
dir="auto">I mean if a line is one mile long and is simplified into five 1000 foot \
segments, I want the longest segment to be 500 feet instead of 1000 \
feet.<br><br></div> <div dir="auto">Get <a href="http://www.bluemail.me/r?b=15774" \
target="_blank">BlueMail for Android</a> </div></div><div style="zoom:0%"> <div \
class="gmail_quote">On Feb 15, 2020, at 11:47 AM, Martin Davis &lt;<a \
href="mailto:mtnclimb@gmail.com" target="_blank">mtnclimb@gmail.com</a>&gt; \
wrote:<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px \
solid rgb(204,204,204);padding-left:1ex"> <div dir="auto">You mean you want to keep \
simplifying until there are no segments of length greater than the maximum?   \
(Presumably excluding input segments already longer?)</div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 14, 2020, 1:57 PM \
Alexander Gataric &lt;<a href="mailto:gataric@usa.net" \
target="_blank">gataric@usa.net</a>&gt; wrote:<br></div><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple" \
style="zoom:0%"><div dir="auto">Is there a way to modify st_simplify to have a \
maximum segment length? I want to be able to limit it to 500 feet.<br><br></div> <div \
dir="auto">Get <a href="http://www.bluemail.me/r?b=15774" rel="noreferrer" \
target="_blank">BlueMail for Android</a> </div> <div \
class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt \
0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"></blockquote></div></div>_______________________________________________<br>
 postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" rel="noreferrer" \
target="_blank">postgis-users@lists.osgeo.org</a><br> <a \
href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer \
noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div>
 <pre><hr><br>postgis-users mailing list<br><a \
href="mailto:postgis-users@lists.osgeo.org" \
target="_blank">postgis-users@lists.osgeo.org</a><br><a \
href="https://lists.osgeo.org/mailman/listinfo/postgis-users" \
target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></pre></blockquote></div></div>_______________________________________________<br>
 postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" \
target="_blank">postgis-users@lists.osgeo.org</a><br> <a \
href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" \
target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div></div>
 <pre><hr><br>postgis-users mailing list<br><a \
href="mailto:postgis-users@lists.osgeo.org" \
target="_blank">postgis-users@lists.osgeo.org</a><br><a \
href="https://lists.osgeo.org/mailman/listinfo/postgis-users" \
target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></pre></blockquote></div></div>_______________________________________________<br>
 postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" \
target="_blank">postgis-users@lists.osgeo.org</a><br> <a \
href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" \
target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div></div>



[Attachment #6 (text/plain)]

_______________________________________________
postgis-users mailing list
postgis-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic