Re: [postgis-users] Custom st_simplify function

2020-02-15 Thread Phil Bartie
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*1
--for better performance you can reduce the 1
--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,1) AS n
WHERE n*100.00/length < 1;






On Sat, 15 Feb 2020 at 19:25, Alexander Gataric  wrote:

> I tried to use st_segmentize but found that the m coordinate gets
> corrupted.
>
> Get BlueMail for Android 
> On Feb 15, 2020, at 12:50 PM, Phil Bartie  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  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 
>>> On Feb 15, 2020, at 11:47 AM, Martin Davis  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 
 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 
>
> ___
> 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
___
postgis-users mailing list
postgis-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users

Re: [postgis-users] Custom st_simplify function

2020-02-15 Thread Alexander Gataric
I tried to use st_segmentize but found that the m coordinate gets corrupted.

⁣Get BlueMail for Android ​

On Feb 15, 2020, 12:50 PM, at 12:50 PM, Phil Bartie  
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 
>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 
>> On Feb 15, 2020, at 11:47 AM, Martin Davis 
>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 
>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 

 ___
 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

Re: [postgis-users] Custom st_simplify function

2020-02-15 Thread Martin Davis
Douglas-Peucker simplification doesn't split segments, it only creates
longer ones.  So not sure what behaviour you are seeing with it?

Can you post an example?

On Sat, Feb 15, 2020, 10:44 AM Alexander Gataric  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 
> On Feb 15, 2020, at 11:47 AM, Martin Davis  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  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 
>>>
>>> ___
>>> 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

Re: [postgis-users] Custom st_simplify function

2020-02-15 Thread Phil Bartie
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  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 
> On Feb 15, 2020, at 11:47 AM, Martin Davis  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  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 
>>>
>>> ___
>>> 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

Re: [postgis-users] Custom st_simplify function

2020-02-15 Thread Alexander Gataric
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 ​

On Feb 15, 2020, 11:47 AM, at 11:47 AM, Martin Davis  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 
>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 
>>
>> ___
>> 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

Re: [postgis-users] Custom st_simplify function

2020-02-15 Thread Martin Davis
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  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 
>
> ___
> 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] Custom st_simplify function

2020-02-14 Thread Alexander Gataric
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 ​

On Feb 14, 2020, 1:13 PM, at 1:13 PM, Regina Obe  wrote:
>gdal_translate does not have a PostGIS raster writer (or at least not
>last time I checked).  So you can’t use it to load rasters into
>PostGIS, but  can use it to output  postgis raster to other formats.
>Need to use raster2pgsql for PostGIS raster loading.
>
>
>
>As far as ogr2ogr vs. shp2gpsql there probably isn’t much of a
>difference between shp2pgsql vs. ogr2ogr.  Both use some variant of
>shapelib library.  Though I think ogr2ogr may make a direct connection
>where as shp2pgsql just generates a script.
>
>That said you could achieve the same in ogr2ogr. So that’s more of a
>limitation of shp2pgsql than a benefit.
>
>
>
>
>
>From: postgis-users [mailto:postgis-users-boun...@lists.osgeo.org] On
>Behalf Of Micha Silver
>Sent: Friday, February 14, 2020 6:03 AM
>To: PostGIS Users Discussion ; Jachym
>Cepicky 
>Subject: Re: [postgis-users] gdal or shp2pgsql
>
>
>
>
>
>On 14/02/2020 12:50, Jachym Cepicky wrote:
>
>Hi all,
>
>I would like to ask, whether you are aware of any big performance
>differences or any other serious reasons, why could shp2pgsql and
>raster2pgsql be preferred over ogr2ogr and gdal_translate ?
>
>
>
>Encoding of attribute tables in shapefiles is often a problem, and
>shp2pgsql has the -W option to help to get it right. I don't know how I
>would duplicate that in ogr2ogr. Maybe with some -lco incantation?
>
>
>
>Thanks, Micha
>
>
>
>
>
>From the users perspective, I can use both tools on similar manner and
>have no problem with "complex" gdal data model and parameters options
>and I would probably prefer the GDAL tools, since it allows me to
>translate between various formats without specifically care, what they
>are, while *2pgsql is always Postgres specific
>
>Maybe one missing feature of the PostGIS native tools: is there
>elegant way (besides of subprocess module), how to use them in
>Python(3) environment?
>
>Thank you for clarification
>
>Jachym
>
>--
>Micha Silver
>Ben Gurion Univ.
>Sde Boker, Remote Sensing Lab
>cell: +972-523-665918
>https://orcid.org/-0002-1128-1325
>
>
>
>
>___
>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