Splitting polygons at narrowest part using R?Removing slivers after splitting a polygon with a lineMapping Russia - Int'l dateline splitting polygonHow to merge single polygons to multi part polygons by maximum distances?Cutting polygon using line - cutter, cut() - using ArcPy?QGIS split line into segments on polygonSplit polygons based on raster layer and defined target sizeSplitting Polygons at midpoint using ArcPy?Splitting polygons with line grid in QGIS?Identifying polygons in two separate layers with a large (>85%) overlapFilling or splitting polygons proportionally based on variables using QGIS?

Are language and thought the same?

How do you manage to study and have a balance in your life at the same time?

Why don't they build airplanes from 3D printer plastic?

How to encode a class with 24,000 categories?

When is it legal to castle moving the rook first?

Count rook moves 1D

How can I let authenticated users rebuild caches?

Generate points for smooth movement between two given points

Are there photos of the Apollo LM showing disturbed lunar soil resulting from descent engine exhaust?

What is the difference between "wie" and "nach" in "Klingt wie/nach..."

Archiving processor does not archive

Do index funds really have double-digit percents annual return rates?

Has Rey's new lightsaber been seen before in canon or legends?

Punishment in pacifist society

Is there any reason to change the ISO manually?

First Number to Contain Each Letter

What does "se jouer" mean here?

What is the most likely cause of short, quick, and useless reviews?

Is it safe for a student to give negative feedback in student evaluations?

Typesetting a comma unless before a line break

Is there a name for this metric: TN / (TN + FN)?

What drugs were used in England during the High Middle Ages?

Does POSIX guarantee the paths to any standard utilities?

What did Boris Johnson mean when he said "extra 34 billion going into the NHS"



Splitting polygons at narrowest part using R?


Removing slivers after splitting a polygon with a lineMapping Russia - Int'l dateline splitting polygonHow to merge single polygons to multi part polygons by maximum distances?Cutting polygon using line - cutter, cut() - using ArcPy?QGIS split line into segments on polygonSplit polygons based on raster layer and defined target sizeSplitting Polygons at midpoint using ArcPy?Splitting polygons with line grid in QGIS?Identifying polygons in two separate layers with a large (>85%) overlapFilling or splitting polygons proportionally based on variables using QGIS?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I have a dataset of polygons like this one:



enter image description here



I would like to split these polygons in separate parts at their most narrow location (if they have one). For example the two small polygons should not be split. So I would need to identify narrow locations and then split the polygon there.



How could this be done using R?










share|improve this question





















  • 2





    Why shouldn't the two smaller polygons be split? They must have a narrowest point if they have any variable width at all. The one lower right looks like its narrowest would cut off the left-most "blob".

    – Spacedman
    8 hours ago







  • 1





    But the small polygon have a narrowest part, how did you determine that they should not split (minimum area, narrowest part smaller than X, other....)

    – J.R
    8 hours ago











  • That's true – maybe some sort of polygon complexity and a size criterion should determine wether a polygon is split or not.

    – Mario
    8 hours ago






  • 2





    Sure, but if you didn't know your own requirement how could we propose a solution ?

    – J.R
    8 hours ago











  • One algorithm might be to find the smallest negative distance (ie internal) buffer that splits the polygon into two polygons, and then somehow use that to decide where to split the polygon. I've not fully worked this out yet...

    – Spacedman
    8 hours ago

















3















I have a dataset of polygons like this one:



enter image description here



I would like to split these polygons in separate parts at their most narrow location (if they have one). For example the two small polygons should not be split. So I would need to identify narrow locations and then split the polygon there.



How could this be done using R?










share|improve this question





















  • 2





    Why shouldn't the two smaller polygons be split? They must have a narrowest point if they have any variable width at all. The one lower right looks like its narrowest would cut off the left-most "blob".

    – Spacedman
    8 hours ago







  • 1





    But the small polygon have a narrowest part, how did you determine that they should not split (minimum area, narrowest part smaller than X, other....)

    – J.R
    8 hours ago











  • That's true – maybe some sort of polygon complexity and a size criterion should determine wether a polygon is split or not.

    – Mario
    8 hours ago






  • 2





    Sure, but if you didn't know your own requirement how could we propose a solution ?

    – J.R
    8 hours ago











  • One algorithm might be to find the smallest negative distance (ie internal) buffer that splits the polygon into two polygons, and then somehow use that to decide where to split the polygon. I've not fully worked this out yet...

    – Spacedman
    8 hours ago













3












3








3


1






I have a dataset of polygons like this one:



enter image description here



I would like to split these polygons in separate parts at their most narrow location (if they have one). For example the two small polygons should not be split. So I would need to identify narrow locations and then split the polygon there.



How could this be done using R?










share|improve this question
















I have a dataset of polygons like this one:



enter image description here



I would like to split these polygons in separate parts at their most narrow location (if they have one). For example the two small polygons should not be split. So I would need to identify narrow locations and then split the polygon there.



How could this be done using R?







r polygon splitting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









PolyGeo

55k17 gold badges87 silver badges258 bronze badges




55k17 gold badges87 silver badges258 bronze badges










asked 8 hours ago









MarioMario

1574 bronze badges




1574 bronze badges










  • 2





    Why shouldn't the two smaller polygons be split? They must have a narrowest point if they have any variable width at all. The one lower right looks like its narrowest would cut off the left-most "blob".

    – Spacedman
    8 hours ago







  • 1





    But the small polygon have a narrowest part, how did you determine that they should not split (minimum area, narrowest part smaller than X, other....)

    – J.R
    8 hours ago











  • That's true – maybe some sort of polygon complexity and a size criterion should determine wether a polygon is split or not.

    – Mario
    8 hours ago






  • 2





    Sure, but if you didn't know your own requirement how could we propose a solution ?

    – J.R
    8 hours ago











  • One algorithm might be to find the smallest negative distance (ie internal) buffer that splits the polygon into two polygons, and then somehow use that to decide where to split the polygon. I've not fully worked this out yet...

    – Spacedman
    8 hours ago












  • 2





    Why shouldn't the two smaller polygons be split? They must have a narrowest point if they have any variable width at all. The one lower right looks like its narrowest would cut off the left-most "blob".

    – Spacedman
    8 hours ago







  • 1





    But the small polygon have a narrowest part, how did you determine that they should not split (minimum area, narrowest part smaller than X, other....)

    – J.R
    8 hours ago











  • That's true – maybe some sort of polygon complexity and a size criterion should determine wether a polygon is split or not.

    – Mario
    8 hours ago






  • 2





    Sure, but if you didn't know your own requirement how could we propose a solution ?

    – J.R
    8 hours ago











  • One algorithm might be to find the smallest negative distance (ie internal) buffer that splits the polygon into two polygons, and then somehow use that to decide where to split the polygon. I've not fully worked this out yet...

    – Spacedman
    8 hours ago







2




2





Why shouldn't the two smaller polygons be split? They must have a narrowest point if they have any variable width at all. The one lower right looks like its narrowest would cut off the left-most "blob".

– Spacedman
8 hours ago






Why shouldn't the two smaller polygons be split? They must have a narrowest point if they have any variable width at all. The one lower right looks like its narrowest would cut off the left-most "blob".

– Spacedman
8 hours ago





1




1





But the small polygon have a narrowest part, how did you determine that they should not split (minimum area, narrowest part smaller than X, other....)

– J.R
8 hours ago





But the small polygon have a narrowest part, how did you determine that they should not split (minimum area, narrowest part smaller than X, other....)

– J.R
8 hours ago













That's true – maybe some sort of polygon complexity and a size criterion should determine wether a polygon is split or not.

– Mario
8 hours ago





That's true – maybe some sort of polygon complexity and a size criterion should determine wether a polygon is split or not.

– Mario
8 hours ago




2




2





Sure, but if you didn't know your own requirement how could we propose a solution ?

– J.R
8 hours ago





Sure, but if you didn't know your own requirement how could we propose a solution ?

– J.R
8 hours ago













One algorithm might be to find the smallest negative distance (ie internal) buffer that splits the polygon into two polygons, and then somehow use that to decide where to split the polygon. I've not fully worked this out yet...

– Spacedman
8 hours ago





One algorithm might be to find the smallest negative distance (ie internal) buffer that splits the polygon into two polygons, and then somehow use that to decide where to split the polygon. I've not fully worked this out yet...

– Spacedman
8 hours ago










1 Answer
1






active

oldest

votes


















5
















Given a polygon pol, like this:



enter image description here



then:



> library(sf)
> sdist = -0.055168
> ppol = splitnarrow(pol, sdist, 1e-3)
> plot(ppol, col=1:2)


produces this:



enter image description here



Here's the source code for splitnarrow. There's a zillion places where this can go wrong, and first you have to determine sdist and eps for your polygons.



splitnarrow <- function(pol, sdist, eps)
###
### split a polygon at its narrowest point.
###

### sdist is the smallest value for internal buffering that splits the
### polygon into a MULTIPOLYGON and needs computing before running this.

### eps is another tolerance that is needed to get the points at which the
### narrowest point is to be cut.

## split the polygon into two separate polygons
bparts = st_buffer(pol, sdist)
features = st_cast(st_sfc(bparts), "POLYGON")

## find where the two separate polygons are closest, this is where
## the internal buffering pinched off into two polygons.

pinch = st_nearest_points(features[1],features[2])

## buffering the pinch point by a slightly larger buffer length should intersect with
## the polygon at the narrow point.
inter = st_intersection(
st_cast(pol,"MULTILINESTRING"),
st_buffer(pinch,-(sdist-(eps))
)
)
join = st_cast(st_sfc(inter), "LINESTRING")

## join is now two small line segments of the polygon across the "waist".
## find the line of closest approach of them:
splitline = st_nearest_points(join[1], join[2])

## that's our cut line. Now put that with the polygon and make new polygons:
mm = st_union(splitline, st_cast(pol, "LINESTRING"))
parts = st_collection_extract(st_polygonize(mm))
parts



sdist is the smallest value that splits the single polygon into a multipolygon, and eps is the smallest value that touches both sides when buffered from the waist intersection point. Finding these could be automated.






share|improve this answer



























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "79"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f333817%2fsplitting-polygons-at-narrowest-part-using-r%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5
















    Given a polygon pol, like this:



    enter image description here



    then:



    > library(sf)
    > sdist = -0.055168
    > ppol = splitnarrow(pol, sdist, 1e-3)
    > plot(ppol, col=1:2)


    produces this:



    enter image description here



    Here's the source code for splitnarrow. There's a zillion places where this can go wrong, and first you have to determine sdist and eps for your polygons.



    splitnarrow <- function(pol, sdist, eps)
    ###
    ### split a polygon at its narrowest point.
    ###

    ### sdist is the smallest value for internal buffering that splits the
    ### polygon into a MULTIPOLYGON and needs computing before running this.

    ### eps is another tolerance that is needed to get the points at which the
    ### narrowest point is to be cut.

    ## split the polygon into two separate polygons
    bparts = st_buffer(pol, sdist)
    features = st_cast(st_sfc(bparts), "POLYGON")

    ## find where the two separate polygons are closest, this is where
    ## the internal buffering pinched off into two polygons.

    pinch = st_nearest_points(features[1],features[2])

    ## buffering the pinch point by a slightly larger buffer length should intersect with
    ## the polygon at the narrow point.
    inter = st_intersection(
    st_cast(pol,"MULTILINESTRING"),
    st_buffer(pinch,-(sdist-(eps))
    )
    )
    join = st_cast(st_sfc(inter), "LINESTRING")

    ## join is now two small line segments of the polygon across the "waist".
    ## find the line of closest approach of them:
    splitline = st_nearest_points(join[1], join[2])

    ## that's our cut line. Now put that with the polygon and make new polygons:
    mm = st_union(splitline, st_cast(pol, "LINESTRING"))
    parts = st_collection_extract(st_polygonize(mm))
    parts



    sdist is the smallest value that splits the single polygon into a multipolygon, and eps is the smallest value that touches both sides when buffered from the waist intersection point. Finding these could be automated.






    share|improve this answer





























      5
















      Given a polygon pol, like this:



      enter image description here



      then:



      > library(sf)
      > sdist = -0.055168
      > ppol = splitnarrow(pol, sdist, 1e-3)
      > plot(ppol, col=1:2)


      produces this:



      enter image description here



      Here's the source code for splitnarrow. There's a zillion places where this can go wrong, and first you have to determine sdist and eps for your polygons.



      splitnarrow <- function(pol, sdist, eps)
      ###
      ### split a polygon at its narrowest point.
      ###

      ### sdist is the smallest value for internal buffering that splits the
      ### polygon into a MULTIPOLYGON and needs computing before running this.

      ### eps is another tolerance that is needed to get the points at which the
      ### narrowest point is to be cut.

      ## split the polygon into two separate polygons
      bparts = st_buffer(pol, sdist)
      features = st_cast(st_sfc(bparts), "POLYGON")

      ## find where the two separate polygons are closest, this is where
      ## the internal buffering pinched off into two polygons.

      pinch = st_nearest_points(features[1],features[2])

      ## buffering the pinch point by a slightly larger buffer length should intersect with
      ## the polygon at the narrow point.
      inter = st_intersection(
      st_cast(pol,"MULTILINESTRING"),
      st_buffer(pinch,-(sdist-(eps))
      )
      )
      join = st_cast(st_sfc(inter), "LINESTRING")

      ## join is now two small line segments of the polygon across the "waist".
      ## find the line of closest approach of them:
      splitline = st_nearest_points(join[1], join[2])

      ## that's our cut line. Now put that with the polygon and make new polygons:
      mm = st_union(splitline, st_cast(pol, "LINESTRING"))
      parts = st_collection_extract(st_polygonize(mm))
      parts



      sdist is the smallest value that splits the single polygon into a multipolygon, and eps is the smallest value that touches both sides when buffered from the waist intersection point. Finding these could be automated.






      share|improve this answer



























        5














        5










        5









        Given a polygon pol, like this:



        enter image description here



        then:



        > library(sf)
        > sdist = -0.055168
        > ppol = splitnarrow(pol, sdist, 1e-3)
        > plot(ppol, col=1:2)


        produces this:



        enter image description here



        Here's the source code for splitnarrow. There's a zillion places where this can go wrong, and first you have to determine sdist and eps for your polygons.



        splitnarrow <- function(pol, sdist, eps)
        ###
        ### split a polygon at its narrowest point.
        ###

        ### sdist is the smallest value for internal buffering that splits the
        ### polygon into a MULTIPOLYGON and needs computing before running this.

        ### eps is another tolerance that is needed to get the points at which the
        ### narrowest point is to be cut.

        ## split the polygon into two separate polygons
        bparts = st_buffer(pol, sdist)
        features = st_cast(st_sfc(bparts), "POLYGON")

        ## find where the two separate polygons are closest, this is where
        ## the internal buffering pinched off into two polygons.

        pinch = st_nearest_points(features[1],features[2])

        ## buffering the pinch point by a slightly larger buffer length should intersect with
        ## the polygon at the narrow point.
        inter = st_intersection(
        st_cast(pol,"MULTILINESTRING"),
        st_buffer(pinch,-(sdist-(eps))
        )
        )
        join = st_cast(st_sfc(inter), "LINESTRING")

        ## join is now two small line segments of the polygon across the "waist".
        ## find the line of closest approach of them:
        splitline = st_nearest_points(join[1], join[2])

        ## that's our cut line. Now put that with the polygon and make new polygons:
        mm = st_union(splitline, st_cast(pol, "LINESTRING"))
        parts = st_collection_extract(st_polygonize(mm))
        parts



        sdist is the smallest value that splits the single polygon into a multipolygon, and eps is the smallest value that touches both sides when buffered from the waist intersection point. Finding these could be automated.






        share|improve this answer













        Given a polygon pol, like this:



        enter image description here



        then:



        > library(sf)
        > sdist = -0.055168
        > ppol = splitnarrow(pol, sdist, 1e-3)
        > plot(ppol, col=1:2)


        produces this:



        enter image description here



        Here's the source code for splitnarrow. There's a zillion places where this can go wrong, and first you have to determine sdist and eps for your polygons.



        splitnarrow <- function(pol, sdist, eps)
        ###
        ### split a polygon at its narrowest point.
        ###

        ### sdist is the smallest value for internal buffering that splits the
        ### polygon into a MULTIPOLYGON and needs computing before running this.

        ### eps is another tolerance that is needed to get the points at which the
        ### narrowest point is to be cut.

        ## split the polygon into two separate polygons
        bparts = st_buffer(pol, sdist)
        features = st_cast(st_sfc(bparts), "POLYGON")

        ## find where the two separate polygons are closest, this is where
        ## the internal buffering pinched off into two polygons.

        pinch = st_nearest_points(features[1],features[2])

        ## buffering the pinch point by a slightly larger buffer length should intersect with
        ## the polygon at the narrow point.
        inter = st_intersection(
        st_cast(pol,"MULTILINESTRING"),
        st_buffer(pinch,-(sdist-(eps))
        )
        )
        join = st_cast(st_sfc(inter), "LINESTRING")

        ## join is now two small line segments of the polygon across the "waist".
        ## find the line of closest approach of them:
        splitline = st_nearest_points(join[1], join[2])

        ## that's our cut line. Now put that with the polygon and make new polygons:
        mm = st_union(splitline, st_cast(pol, "LINESTRING"))
        parts = st_collection_extract(st_polygonize(mm))
        parts



        sdist is the smallest value that splits the single polygon into a multipolygon, and eps is the smallest value that touches both sides when buffered from the waist intersection point. Finding these could be automated.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 7 hours ago









        SpacedmanSpacedman

        28.5k2 gold badges37 silver badges56 bronze badges




        28.5k2 gold badges37 silver badges56 bronze badges






























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f333817%2fsplitting-polygons-at-narrowest-part-using-r%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

            The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

            19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу