简体   繁体   中英

ST_MAKEPOLYGON inverse function

Is there a function to inverse the ST_MAKEPOLYGON and get a linestring from a polygon?

The best option I have found so far is to modify the geometry at the WKB level.

with data AS (
  SELECT ST_MAKEPOLYGON(ST_MAKELINE([
    ST_GEOGPOINT(7.48,6.74),
    ST_GEOGPOINT(7.50,6.73),
    ST_GEOGPOINT(7.47,6.76),
    ST_GEOGPOINT(7.48,6.74)
  ])) AS my_polygon
    )
SELECT
  ST_GEOGFROMWKB(CONCAT(b'\x01\x02',SUBSTR(ST_ASBINARY(my_polygon),7)))
FROM data

Try below

SELECT ST_EXTERIORRING(my_polygon)     

If applied to sample data in your question - output is

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM