7

I have a LineString geometry which is U shaped like and I'd like to find the center point of the geometry which lies on the LineString. I've already used st_centroid but the returned geometry isn't on the LineString.

I would like to know which function should be used in PostGIS to achieve that?

  • 1
    Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq. – underdark Sep 3 '17 at 11:18
  • It would also help to show what you mean by "actual center". Perhaps read workshops.boundlessgeo.com/postgis-intro/… – BradHards Sep 3 '17 at 11:40
  • @underdark Thanks for the response. I edited the question. – mohammad reza Sep 3 '17 at 11:57
  • @BradHards I'll read the article, that's what I'm looking for. Thanks! – mohammad reza Sep 3 '17 at 12:02
12

The documentation for st_centroid, st_pointOnSurface and st_line_interpolate_point have neat images describing them.

st_centroid gives you the geometric centroid point, which can be outside of the source geometry (think of a line shaped as a U, the centroid will not be on the line).

st_pointOnSurface returns a point that is for sure on the surface (on the line, inside a polygon), but you don't know where it is. It is very useful for label placement.

st_line_interpolate_point, used with a parameter of .5 (50%) will return the point, on the input line, located in the middle.

  • 1
    Answer was relevant to original question... Not so much for the completly changed one – JGH Sep 3 '17 at 13:08

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.