2

I have a GIS layer of bus stops (MultiLineString), which contain the paint lines that are painted on the asphalt.

enter image description here

The complete bus stop element is in a single MultiLine element. If I select it:

enter image description here

I need to know the length of the bus stop to know the total number of meters to act on the adjacent curb. Is there a method to achieve this?

enter image description here

I have 100+ bus stops. Some examples:

enter image description here

enter image description here

enter image description here

5

1 Answer 1

1

The query I was able to make with the hints in the comments above and that worked for me:

WITH 
  bbox AS (
    SELECT id, ST_OrientedEnvelope(the_geom) as geom
    FROM mytable
  ),
  corners AS (
    SELECT id,(ST_DumpPoints(geom)).geom AS geom
    FROM bbox
  ),
  distances AS (
    SELECT a.id, ST_Distance(a.geom, b.geom) AS distance
    FROM corners a, corners b
    WHERE NOT ST_Equals(a.geom, b.geom) AND a.id=b.id
  )

SELECT id, MAX(distance) as distance
FROM distances
GROUP BY id;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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