2

I am using spatialite and it does not contains the method ST_dumppoints and ST_dump. I want to divide several linestring into smaller parts. I also have points that I combined and that resulted in a linestrings. Now I want to divide these linestring into several parts.

I have tried using ST_line_substring and ST_line_locate_point but nothing is working.

Is there a way to divide linestring into smaller segments say 100m in spatialite?

What I have done is:

select 
ASText(ST_Line_Substring(linearea.geometry,0,
ST_Line_Locate_Point(linearea.geometry, Transform(setsrid(pointarea.geometry,4326),3857))))  AS Geometry
from LineArea linearea,PointArea pointarea

PontArea is Area which I combined to make LineArea using MakeLine(ST_point(long,lat))
  • There is a function for that in gaia-gis.it/gaia-sins/spatialite-sql-latest.html. – user30184 Sep 26 '17 at 12:05
  • @user30184 for what? – mimetype Sep 26 '17 at 12:06
  • Are you talking about ST_segmentize well I have used it. it is not working – mimetype Sep 26 '17 at 12:09
  • Wait, do you want more vertices to your lines or really cut them so that you will have many short linestrings? Segment is what you have between two vertices. ST_Segmantize is adding vertices and makes shorter segments but it feels like you are not satisfied with small segments really. – user30184 Sep 26 '17 at 12:09
  • @user30184 I just to cut them so that small linestrings are made of one large linestring – mimetype Sep 26 '17 at 12:11
2

I would point you to using the ST_Line_Substring:

Return a linestring being a substring of the input one starting and ending at the given fractions of total 2d length. Second and third arguments are float8 values between 0 and 1.

Return a linestring being a substring of the input one starting and ending at the given fractions of total 2d length. Second and third arguments are float8 values between 0 and 1. This only works with LINESTRINGs. To use with contiguous MULTILINESTRINGs use in conjunction with ST_LineMerge.

enter image description here

A linestring seen with 1/3 midrange overlaid (0.333, 0.666)

  • Thanks for answers.Yes I know it but can you give an example code for that? – mimetype Sep 26 '17 at 13:11
  • I've added a link to the documentation as well as the sample code they provided. – whyzar Sep 26 '17 at 13:16
  • what you have added is a sample code and it will not work in spatialite. – mimetype Sep 26 '17 at 13:24
  • I've removed the previous sample code, let me see if I can dig up something. – whyzar Sep 26 '17 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.