[postgis-users] Custom st_simplify function
Phil Bartie
philbartie at gmail.com
Sat Feb 15 12:02:20 PST 2020
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 at 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 at 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 at 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 at 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 at 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 at lists.osgeo.org
>>>>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>>>
>>>> ------------------------------
>>>>
>>>> postgis-users mailing list
>>>> postgis-users at lists.osgeo.org
>>>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>>>
>>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>
>> ------------------------------
>>
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>
>> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20200215/d4c5c957/attachment.html>
More information about the postgis-users
mailing list