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?

Why did the Joi advertisement trigger K?

How to generate all 3×3 matrices with a,a,a,a,b,b,b,c,c?

How does Harry wear the invisibility cloak?

Do I need to get a noble in order to win Splendor?

Case Studies and Real Problems for Teaching Optimization and Modelling

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

How do I stop making people jump at home and at work?

Is it rude to ask my opponent to resign an online game when they have a lost endgame?

How could it be that the capo isn't changing the pitch?

The little bee buzzes around the flower garden

std::tuple sizeof, is it a missed optimization?

How will the UK Commons debate tonight despite the prorogation?

In-universe, why does Doc Brown program the time machine to go to 1955?

How can I oppose my advisor granting gift authorship to a collaborator?

Confusion in understanding control system?

co-son-in-law or co-brother

MOSFET broke after attaching capacitor bank

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

Finder/Terminal: Find files that contain less than 21 lines of text

When making yogurt, why doesn't bad bacteria grow as well?

Splitting polygons at narrowest part using R?

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

How did Gollum know Sauron was gathering the Haradrim to make war?

'This one' as a pronoun



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;








4















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
    10 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
    10 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
    10 hours ago






  • 2





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

    – J.R
    10 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
    10 hours ago

















4















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
    10 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
    10 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
    10 hours ago






  • 2





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

    – J.R
    10 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
    10 hours ago













4












4








4


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 5 hours ago









PolyGeo

55k17 gold badges87 silver badges258 bronze badges




55k17 gold badges87 silver badges258 bronze badges










asked 10 hours ago









MarioMario

1624 bronze badges




1624 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
    10 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
    10 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
    10 hours ago






  • 2





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

    – J.R
    10 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
    10 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
    10 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
    10 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
    10 hours ago






  • 2





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

    – J.R
    10 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
    10 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
10 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
10 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
10 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
10 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
10 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
10 hours ago




2




2





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

– J.R
10 hours ago





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

– J.R
10 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
10 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
10 hours ago










2 Answers
2






active

oldest

votes


















6
















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
































    0
















    This would take you rather far afield,
    but one way to define the most narrow waist
    of a shape is to identify the event at which the
    straight skeleton partitions
    the shrinking shape into two pieces.




             


             

    Image from here (and probably copied from elsewhere).


    You can view the polygon boundary edges moving inward at a fixed rate.
    A narrow neck will pinch off the shape into two pieces. In the
    above image, this happens a bit beyond t=4.




    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

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      6
















      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





























        6
















        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



























          6














          6










          6









          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 9 hours ago









          SpacedmanSpacedman

          28.5k2 gold badges37 silver badges56 bronze badges




          28.5k2 gold badges37 silver badges56 bronze badges


























              0
















              This would take you rather far afield,
              but one way to define the most narrow waist
              of a shape is to identify the event at which the
              straight skeleton partitions
              the shrinking shape into two pieces.




                       


                       

              Image from here (and probably copied from elsewhere).


              You can view the polygon boundary edges moving inward at a fixed rate.
              A narrow neck will pinch off the shape into two pieces. In the
              above image, this happens a bit beyond t=4.




              share|improve this answer





























                0
















                This would take you rather far afield,
                but one way to define the most narrow waist
                of a shape is to identify the event at which the
                straight skeleton partitions
                the shrinking shape into two pieces.




                         


                         

                Image from here (and probably copied from elsewhere).


                You can view the polygon boundary edges moving inward at a fixed rate.
                A narrow neck will pinch off the shape into two pieces. In the
                above image, this happens a bit beyond t=4.




                share|improve this answer



























                  0














                  0










                  0









                  This would take you rather far afield,
                  but one way to define the most narrow waist
                  of a shape is to identify the event at which the
                  straight skeleton partitions
                  the shrinking shape into two pieces.




                           


                           

                  Image from here (and probably copied from elsewhere).


                  You can view the polygon boundary edges moving inward at a fixed rate.
                  A narrow neck will pinch off the shape into two pieces. In the
                  above image, this happens a bit beyond t=4.




                  share|improve this answer













                  This would take you rather far afield,
                  but one way to define the most narrow waist
                  of a shape is to identify the event at which the
                  straight skeleton partitions
                  the shrinking shape into two pieces.




                           


                           

                  Image from here (and probably copied from elsewhere).


                  You can view the polygon boundary edges moving inward at a fixed rate.
                  A narrow neck will pinch off the shape into two pieces. In the
                  above image, this happens a bit beyond t=4.





                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 46 mins ago









                  Joseph O'RourkeJoseph O'Rourke

                  2312 silver badges4 bronze badges




                  2312 silver badges4 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

                      Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                      Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                      Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її