1

I'm interested in using OGR/GDAL, PostGIS, or QGIS in order to achieve the following:

Working from the PostGIS docs, how would one further simplify this line to the middle line? I've tried utilizing the ST_Simplify function as well as the ST_SimplifyVW and it doesn't seem to have any affect. Here is an example of what is depicted on the docs:

SELECT ST_GeomFromText('POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))',4326)

Here is what I've tried:

SELECT st_simplifyvw(ST_StraightSkeleton(st_union(ST_GeomFromText('POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))',4326))),10);

And basically what I'm trying to extract is the black line by trimming the branches off (so to speak):

enter image description here

1

1 Answer 1

0

A simple approach to "trim the branches" could be by longitude but is not a complete solution.

with lines as (
SELECT 
st_subdivide(
st_straightskeleton( ST_GeomFromText('POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))',4326)), 5) segment
,st_length(
st_subdivide(
st_straightskeleton( ST_GeomFromText('POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))',4326)), 5)) longitude ) 
select segment from lines where longitude>20;
1
  • Thanks Pepe, but this will not suffice in this scenario, I think I may look into the OGR centerline library to accomplish this.
    – Matt
    May 19 at 14:28

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.