1

I have a trajectory given by GPS which I store as a ST_LineString() and I'd like to know the area covered by the line string. I know the "width" of the trajectory, but I'm not sure how to approach the problem.

I thought the following steps might do what I want.

  1. break line string into an array of two-point segments (simple lines)
  2. create a rectangle from the two-point-line and width
  3. call st_unionaggr() over all rectangles to create one polygon and then call st_area() on it

example

So my question is: Is there an effective way to create a rectangle from given line and width? And if so, do you think this solution is viable or is there a more elegant way to do it?

| improve this question | | | | |
  • 1
    What if you consider a buffer ST_Buffer() with round end caps and joins? – Taras Aug 21 '19 at 11:28
  • 2
    Why not just buffer the line and use that polygon? – Ian Turton Aug 21 '19 at 11:28
  • Thanks for the hint; that would do exactly what I need. Unfortunately I run an SAP SQL Anywhere server so I checked the manual and it says this is a list of unsupported methods: ST_Buffer, ST_LocateAlong, ST_LocateBetween, ST_Segmentize, ST_Simplify, ST_Distance_Spheroid , ST_Length_Spheroid – Jan J Aug 21 '19 at 11:53
  • What about ST_ConvexHull? – DPSSpatial Aug 21 '19 at 18:18
  • ST_ConvexHull() might work as a good approximation in some cases, I'll try to work with it since it's probably the best option for now. In the meantime I'll try to force my company to upgrade the db server to a newer version which already supports method st_buffer(). I'm not interested in implementing Minkowski sum on my own really :) Thank you all for your answers. – Jan J Aug 22 '19 at 8:29
0

As Taras and Ian Turton suggested, function ST_Buffer() is the best solution for this problem, even though my version of the db server doesn't support it yet.

| improve this answer | | | | |
  • There are other tools also available to create buffer and calculate area, that doesn't need a db server. Which programming language are you using? – neogeomat Aug 26 '19 at 23:03

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.